From ef034acd41845a2e589a6c9a06a4e597afaa85df Mon Sep 17 00:00:00 2001 From: Nathan Douglas Date: Tue, 10 Oct 2023 09:58:59 -0400 Subject: [PATCH 1/2] VACMS-15617: Fix composer.lock check. --- .github/workflows/continuous_integration.yml | 39 +++++++++++++------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index 0b031d849e..ab56b41bc3 100644 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -167,14 +167,6 @@ jobs: uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 with: fetch-depth: 0 - - name: Delete any existing comment. - uses: thollander/actions-comment-pull-request@d61db783da9abefc3437960d0cce08552c7c004f # v2.4.2 - continue-on-error: true - with: - comment_tag: check-composer-lock-changes - mode: delete - message: | - Checking composer.lock changes... - name: Check changes in composer.lock. run: | LINES_CHANGED=$(git diff --numstat origin/main..HEAD -- composer.lock | awk '{print $1+$2}') @@ -183,16 +175,37 @@ jobs: >&2 echo "THRESHOLD=$THRESHOLD" echo "LINES_CHANGED=$LINES_CHANGED" >> $GITHUB_ENV echo "THRESHOLD=$THRESHOLD" >> $GITHUB_ENV + - name: Comment if composer.lock changes exceed threshold. - uses: thollander/actions-comment-pull-request@d61db783da9abefc3437960d0cce08552c7c004f # v2.4.2 if: env.LINES_CHANGED > env.THRESHOLD continue-on-error: true - with: - comment_tag: check-composer-lock-changes - message: | + run: | + # Find comments containing token, if any, and delete them. + gh api \ + -H "Accept: application/vnd.github+json" \ + /repos/${GITHUB_REPOSITORY}/issues/${GITHUB_PR}/comments \ + | jq '.[] | select(.body | contains("")).id' \ + | while read -r pr_comment; do \ + gh api \ + --method DELETE \ + -H "Accept: application/vnd.github+json" \ + "/repos/${GITHUB_REPOSITORY}/issues/comments/${pr_comment}"; \ + done; + + body="$(awk 'FNR==1 && NR!=1 {print "\n
\n"}{print}' ./.pr_advice/*.md)"; + + # Create a new comment containing the compiled advice. + gh api \ + --method POST \ + -H "Accept: application/vnd.github+json" \ + /repos/${GITHUB_REPOSITORY}/issues/${GITHUB_PR}/comments \ + -f body=" The number of lines changed in composer.lock exceeds the acceptable threshold. - Lines changed: ${{ env.LINES_CHANGED }} - Threshold: ${{ env.THRESHOLD }} - This is a warning only. Please review the changes and ensure that they are acceptable. + This is a warning only. Please review the changes and ensure that they are acceptable."; + env: + GITHUB_PR: "${{ github.event.pull_request.number }}" + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} From e75134c316018d9f72a135cb1bca88d1378d7189 Mon Sep 17 00:00:00 2001 From: Nate Douglas Date: Tue, 14 Nov 2023 08:16:11 -0500 Subject: [PATCH 2/2] Update .github/workflows/continuous_integration.yml --- .github/workflows/continuous_integration.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index ab56b41bc3..763e55c4da 100644 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -194,7 +194,7 @@ jobs: body="$(awk 'FNR==1 && NR!=1 {print "\n
\n"}{print}' ./.pr_advice/*.md)"; - # Create a new comment containing the compiled advice. + # Create a new comment containing the complaint. gh api \ --method POST \ -H "Accept: application/vnd.github+json" \