diff --git a/.gitea/workflows/maintenance.yaml b/.gitea/workflows/maintenance.yaml index 2de1609..92bd9fd 100644 --- a/.gitea/workflows/maintenance.yaml +++ b/.gitea/workflows/maintenance.yaml @@ -3,6 +3,9 @@ name: Auto Maintenance Cycle on: schedule: - cron: 0 1 * * * + push: + paths: + - .gitea/workflows/maintenance.yaml workflow_dispatch: jobs: @@ -17,7 +20,9 @@ jobs: shell: bash - run: pre-commit autoupdate shell: bash + - run: pre-commit run -a - name: Commit + id: auto-commit-action uses: stefanzweifel/git-auto-commit-action@v5 with: commit_message: 'chore: update pre-commit hooks' @@ -26,7 +31,7 @@ jobs: create_branch: true - name: Generate Date run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV - - name: Create an PR action + - name: Create an PR if: steps.auto-commit-action.outputs.changes_detected == 'true' uses: ./ with: @@ -34,5 +39,3 @@ jobs: branch: update/pre-commit-hooks title: Updates to the pre-commit action created at ${{ env.CURRENT_DATE }} body: Update to the pre-commit action. - assignees: Philipp - reviewers: Philipp diff --git a/.gitignore b/.gitignore index 053c255..a7014f8 100644 --- a/.gitignore +++ b/.gitignore @@ -189,4 +189,3 @@ replay_pid* # ---> PuTTY # Private key *.ppk - diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 85cbd02..8512d09 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,3 +1,4 @@ +exclude: ^node_modules/ repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.5.0 @@ -34,7 +35,7 @@ repos: args: [--autofix] - repo: https://github.com/frnmst/md-toc - rev: 8.2.2 + rev: 8.2.0 hooks: - id: md-toc diff --git a/action.yml b/action.yml index 788485e..8d2b9b1 100644 --- a/action.yml +++ b/action.yml @@ -7,9 +7,6 @@ inputs: branch: description: Branch for which to create the PR required: true - base_branch: - description: Branch in which should be mergbed. Defaults to main. - required: false title: description: Title of the pull request required: true @@ -17,6 +14,9 @@ inputs: description: Body of the pull request required: false default: Some default body! + base_branch: + description: Branch in which should be mergbed. Defaults to main. + required: false assignees: description: Comma-separated list of assignees for the pull request required: false diff --git a/index.js b/index.js index a071824..dc77308 100644 --- a/index.js +++ b/index.js @@ -2,8 +2,6 @@ const core = require("@actions/core"); async function getAndPostPullRequests() { try { - core.info("Starting the action..."); - // Retrieve inputs and token const baseUrl = core.getInput("base_url") || "https://git.horstenkamp.eu"; const owner = core.getInput("owner") || process.env.GITHUB_REPOSITORY_OWNER; @@ -36,11 +34,11 @@ async function getAndPostPullRequests() { // Prepare POST data const postData = { title: title, - body: body, + body: body ? body : undefined, head: branch, base: base_branch, - assignees: assigneesInput ? assigneesInput.split(",") : [], - reviewers: reviewersInput ? reviewersInput.split(",") : [], + assignees: assigneesInput ? assigneesInput.split(",") : undefined, + reviewers: reviewersInput ? reviewersInput.split(",") : undefined, due_date: dueDate || undefined, milestone: milestone ? parseInt(milestone, 10) : 0, }; @@ -53,7 +51,10 @@ async function getAndPostPullRequests() { headers, body: JSON.stringify(postData), }); - + if (postResponse.status === 409) { + core.warning("PR between the branches already exists."); + return; + } if (!postResponse.ok) { throw new Error( `HTTP error! status on creating a new PR: ${postResponse.status}`,