From 91b993456e559eefe5a457d85e932bd2593d8c3c Mon Sep 17 00:00:00 2001 From: Nic Crane Date: Mon, 17 Mar 2025 19:05:26 +0000 Subject: [PATCH 1/5] Add Peer Review verification action --- .github/workflows/on_pr.yaml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/on_pr.yaml diff --git a/.github/workflows/on_pr.yaml b/.github/workflows/on_pr.yaml new file mode 100644 index 0000000..8c4412b --- /dev/null +++ b/.github/workflows/on_pr.yaml @@ -0,0 +1,29 @@ +name: Preflight Checks + +on: + pull_request: + branches: + - main + types: [opened, synchronize] + +jobs: + generate: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + repository: ${{ github.event.pull_request.head.repo.full_name }} + ref: ${{ github.event.pull_request.head.ref }} + + - name: Setup Helm + uses: azure/setup-helm@v4 + + - name: Helm Lint + id: lint + run: helm lint + working-directory: charts/zigbee2mqtt + + - name: Run helm-docs + uses: losisin/helm-docs-github-action@v1 + with: + fail-on-diff: true From 29e137e702295568941066f305eb53068a5a04fa Mon Sep 17 00:00:00 2001 From: Nic Crane Date: Mon, 17 Mar 2025 19:14:04 +0000 Subject: [PATCH 2/5] adding PR comment --- .github/workflows/on_pr.yaml | 43 ++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/.github/workflows/on_pr.yaml b/.github/workflows/on_pr.yaml index 8c4412b..bb8c19e 100644 --- a/.github/workflows/on_pr.yaml +++ b/.github/workflows/on_pr.yaml @@ -24,6 +24,49 @@ jobs: working-directory: charts/zigbee2mqtt - name: Run helm-docs + id: docs uses: losisin/helm-docs-github-action@v1 with: fail-on-diff: true + + - name: Post Comment to PR + if: ${{ failure() || success() }} + uses: actions/github-script@v7 + env: + PLAN: "Terraform Plan\n${{ env.plan }}\n${{ steps.plan.outputs.stderr }}" + continue-on-error: true + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + // 1. Retrieve existing bot comments for the PR + const { data: comments } = await github.rest.issues.listComments({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + }) + const botComment = comments.find(comment => { + return comment.user.type === 'Bot' && comment.body.includes('Helm Lint') + }) + + // 2. Prepare format of the comment + const output = `#### Helm Lint 🖌\`${{ steps.lint.outcome }}\` + #### Helm Docs Updated 📚\`${{ steps.docs.outcome }}\` + + *Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\` + + // 3. If we have a comment, update it, otherwise create a new one + if (botComment) { + github.rest.issues.updateComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: botComment.id, + body: output + }) + } else { + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: output + }) + } From ebcc0bd204b05cd86280d08409988c1e2cfb6fca Mon Sep 17 00:00:00 2001 From: Nic Crane Date: Mon, 17 Mar 2025 19:14:29 +0000 Subject: [PATCH 3/5] remove redundant reference --- .github/workflows/on_pr.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/on_pr.yaml b/.github/workflows/on_pr.yaml index bb8c19e..25806d0 100644 --- a/.github/workflows/on_pr.yaml +++ b/.github/workflows/on_pr.yaml @@ -32,8 +32,6 @@ jobs: - name: Post Comment to PR if: ${{ failure() || success() }} uses: actions/github-script@v7 - env: - PLAN: "Terraform Plan\n${{ env.plan }}\n${{ steps.plan.outputs.stderr }}" continue-on-error: true with: github-token: ${{ secrets.GITHUB_TOKEN }} From 6e2e48debe9319fe7db418491503a7904e44284c Mon Sep 17 00:00:00 2001 From: Nic Crane Date: Mon, 17 Mar 2025 19:16:59 +0000 Subject: [PATCH 4/5] correcting syntax --- .github/workflows/on_pr.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/on_pr.yaml b/.github/workflows/on_pr.yaml index 25806d0..726b396 100644 --- a/.github/workflows/on_pr.yaml +++ b/.github/workflows/on_pr.yaml @@ -50,7 +50,7 @@ jobs: const output = `#### Helm Lint 🖌\`${{ steps.lint.outcome }}\` #### Helm Docs Updated 📚\`${{ steps.docs.outcome }}\` - *Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\` + *Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`*`; // 3. If we have a comment, update it, otherwise create a new one if (botComment) { From eb24006ad063b52d5d58505be6d67890e6d89152 Mon Sep 17 00:00:00 2001 From: Nic Crane Date: Mon, 17 Mar 2025 19:25:10 +0000 Subject: [PATCH 5/5] naming --- .github/workflows/on_pr.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/on_pr.yaml b/.github/workflows/on_pr.yaml index 726b396..fbfbd11 100644 --- a/.github/workflows/on_pr.yaml +++ b/.github/workflows/on_pr.yaml @@ -7,7 +7,7 @@ on: types: [opened, synchronize] jobs: - generate: + verify: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4