First draft.
This commit is contained in:
parent
ac99073c40
commit
cf5e817ab3
39
.gitea/workflows/maintenance.yaml
Normal file
39
.gitea/workflows/maintenance.yaml
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
name: Auto Maintenance Cycle
|
||||||
|
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
- cron: '* 1 * * 0'
|
||||||
|
push:
|
||||||
|
#paths:
|
||||||
|
#- .gitea/workflows/maintenance.yaml
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
auto-update:
|
||||||
|
name: pre-commit Autoupdate
|
||||||
|
runs-on: pi64
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
ssh-key: ${{ secrets.DEPLOY_KEY }}
|
||||||
|
ref: main
|
||||||
|
ssh-strict: false
|
||||||
|
|
||||||
|
- uses: actions/setup-python@v4
|
||||||
|
|
||||||
|
- run: pip install pre-commit
|
||||||
|
shell: bash
|
||||||
|
- run: pre-commit autoupdate
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- uses: stefanzweifel/git-auto-commit-action@v5
|
||||||
|
with:
|
||||||
|
commit_message: 'chore: update pre-commit hooks'
|
||||||
|
branch: update/pre-commit-hooks
|
||||||
|
push_options: --force
|
||||||
|
create_branch: true
|
||||||
|
|
||||||
|
- name: Run My Action
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
branch: ${{ github.ref }}
|
||||||
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
49
.pre-commit-config.yaml
Normal file
49
.pre-commit-config.yaml
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
repos:
|
||||||
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
|
rev: v4.5.0
|
||||||
|
hooks:
|
||||||
|
- id: end-of-file-fixer
|
||||||
|
exclude: (.txt$|.ipynb$|README.md$|readme.mde$)
|
||||||
|
- id: trailing-whitespace
|
||||||
|
exclude: (.txt$|README.md$)
|
||||||
|
- id: check-yaml
|
||||||
|
- id: check-json
|
||||||
|
- id: check-toml
|
||||||
|
- id: check-xml
|
||||||
|
- id: check-added-large-files
|
||||||
|
args: [--enforce-all]
|
||||||
|
- id: name-tests-test
|
||||||
|
- id: detect-private-key
|
||||||
|
- id: check-case-conflict
|
||||||
|
- id: check-symlinks
|
||||||
|
- id: check-docstring-first
|
||||||
|
- id: pretty-format-json
|
||||||
|
- id: check-merge-conflict
|
||||||
|
- id: no-commit-to-branch
|
||||||
|
args: [--branch, main]
|
||||||
|
|
||||||
|
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
|
||||||
|
rev: v2.11.0
|
||||||
|
hooks:
|
||||||
|
- id: pretty-format-ini
|
||||||
|
args: [--autofix]
|
||||||
|
- id: pretty-format-toml
|
||||||
|
args: [--autofix]
|
||||||
|
- id: pretty-format-yaml
|
||||||
|
args: [--autofix]
|
||||||
|
|
||||||
|
- repo: https://github.com/frnmst/md-toc
|
||||||
|
rev: 8.2.2
|
||||||
|
hooks:
|
||||||
|
- id: md-toc
|
||||||
|
|
||||||
|
- repo: https://github.com/Lucas-C/pre-commit-hooks-java
|
||||||
|
rev: 1.3.10
|
||||||
|
hooks:
|
||||||
|
- id: validate-html
|
||||||
|
|
||||||
|
- repo: https://github.com/pre-commit/mirrors-prettier
|
||||||
|
rev: v3.1.0
|
||||||
|
hooks:
|
||||||
|
- id: prettier
|
||||||
|
types_or: [css, javascript]
|
40
index.js
Normal file
40
index.js
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
const core = require("@actions/core");
|
||||||
|
const github = require("@actions/github");
|
||||||
|
const { Octokit } = require("@octokit/rest");
|
||||||
|
|
||||||
|
async function run() {
|
||||||
|
try {
|
||||||
|
const branch = core.getInput("branch");
|
||||||
|
const token = core.getInput("github_token");
|
||||||
|
const octokit = new Octokit({ auth: token });
|
||||||
|
const context = github.context;
|
||||||
|
|
||||||
|
// Check for existing PRs
|
||||||
|
const { data: pullRequests } = await octokit.rest.pulls.list({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
head: `${context.repo.owner}:${branch}`,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (pullRequests.length > 0) {
|
||||||
|
console.log("A pull request already exists for this branch.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Creating a new PR
|
||||||
|
const newPr = await octokit.rest.pulls.create({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
title: "Your PR Title", // Customize your PR title
|
||||||
|
head: branch,
|
||||||
|
base: "main", // Change this to your default branch if it's not 'main'
|
||||||
|
body: "Your PR description", // Customize your PR description
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log(`Created a new pull request: ${newPr.data.html_url}`);
|
||||||
|
} catch (error) {
|
||||||
|
core.setFailed(`Action failed with error ${error}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
run();
|
Loading…
x
Reference in New Issue
Block a user