From a1c915f47d331661297837321d781bff085529ae Mon Sep 17 00:00:00 2001 From: aramissennyeydd Date: Tue, 10 Dec 2024 18:41:57 -0700 Subject: [PATCH] fix: breaking API changes comment Signed-off-by: aramissennyeydd --- .../api-breaking-changes-comment.yml | 30 ++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/.github/workflows/api-breaking-changes-comment.yml b/.github/workflows/api-breaking-changes-comment.yml index 1210db0ccf..c2de460fa4 100644 --- a/.github/workflows/api-breaking-changes-comment.yml +++ b/.github/workflows/api-breaking-changes-comment.yml @@ -20,6 +20,7 @@ jobs: git-ref: ${{ steps.event.outputs.GIT_REF }} pr-number: ${{ steps.event.outputs.PR_NUMBER }} action: ${{ steps.event.outputs.ACTION }} + comment-cache-key: ${{ steps.hash.outputs.COMMENT_FILE_HASH }} steps: - name: Harden Runner uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 @@ -64,21 +65,29 @@ jobs: echo ACTION=$(jq --raw-output '.action | tostring | [scan("\\w+")][0]' < event.json) >> $GITHUB_OUTPUT echo GIT_REF=$(jq --raw-output '.pull_request.head.sha | tostring | [scan("\\w+")][0]' < event.json) >> $GITHUB_OUTPUT + - name: Fetch Command and Calculate Hash + id: hash + run: | + unzip preview-spec.zip comment.md + ls + echo "COMMENT_FILE_HASH=$(md5sum comment.md | awk '{ print $1 }')" >> $GITHUB_OUTPUT + + - name: Cache Comment + if: ${{ steps.event.outputs.ACTION != 'closed' }} + uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 + with: + path: comment.md + key: ${{ steps.hash.outputs.COMMENT_FILE_HASH }} + - name: DEBUG - Print Job Outputs if: ${{ runner.debug }} run: | echo "PR number: ${{ steps.event.outputs.PR_NUMBER }}" echo "Git Ref: ${{ steps.event.outputs.GIT_REF }}" echo "Action: ${{ steps.event.outputs.ACTION }}" + echo "Hash: ${{ steps.hash.outputs.COMMENT_FILE_HASH }}" cat event.json - - name: Get Comment - id: get-comment - run: | - unzip preview-spec.zip comment.md - ls - grep - add-comment: name: Write comment about issues needs: @@ -92,6 +101,13 @@ jobs: - name: Checkout uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 + - name: Fetch cached Manifests File + id: cache + uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4 + with: + path: comment.md + key: ${{ needs.setup.outputs.comment-cache-key }} + # Identify comment to be updated - name: Find comment for API Changes uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e # v3