From 769d1817b0e37416bbda01fa8148012c97a52dc2 Mon Sep 17 00:00:00 2001 From: MoritzWeber Date: Wed, 4 Sep 2024 11:14:09 +0200 Subject: [PATCH] ci: Replace existing commitlint PR comments This can avoid a spam of comments when the comment is ignored. Instead, alter the existing comment. --- .github/workflows/commits.yml | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/.github/workflows/commits.yml b/.github/workflows/commits.yml index ee67c2fc0..637f1af28 100644 --- a/.github/workflows/commits.yml +++ b/.github/workflows/commits.yml @@ -11,6 +11,9 @@ jobs: conventional-commits: runs-on: ubuntu-latest if: github.actor != 'dependabot[bot]' + concurrency: + group: commit-check-pr-${{ github.event.pull_request.number }} + cancel-in-progress: true steps: - uses: actions/checkout@v4 with: @@ -29,11 +32,21 @@ jobs: npx commitlint --from "$SHA_FROM" --to "$SHA_TO" >> "$GITHUB_OUTPUT" 2>&1 || r=$? echo "$delim" >> "$GITHUB_OUTPUT" exit $r + - name: Find conventional commit comment on PR + uses: peter-evans/find-comment@v3 + if: always() && steps.conventional-commits.outcome == 'failure' + id: fc + with: + issue-number: ${{ github.event.pull_request.number }} + comment-author: 'github-actions[bot]' + body-includes: conventional commit - name: Post comment if validation failed + uses: peter-evans/create-or-update-comment@v4 if: always() && steps.conventional-commits.outcome == 'failure' - uses: actions/github-script@v7 - env: - TEXT: |- + with: + comment-id: ${{ steps.fc.outputs.comment-id }} + issue-number: ${{ github.event.pull_request.number }} + body: | The pull request does not conform to the conventional commit specification. Please ensure that your commit messages follow the spec: . We also strongly recommend that you set up your development environment with pre-commit, as described in our [Developer documentation](https://dsd-dbs.github.io/capella-collab-manager/development/). This will run all the important checks right before you commit your changes, and avoids lengthy CI wait time and round trips. @@ -48,11 +61,4 @@ jobs: docs(user): Add model creation workflow feat: Add a monitoring dashboard ``` - with: - script: | - github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: process.env.TEXT - }) + edit-mode: replace