diff --git a/.github/workflows/api-breaking-changes-comment.yml b/.github/workflows/api-breaking-changes-comment.yml index 1593417e5d..cc47eb3b8e 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@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4 @@ -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