From 56a105828fabc7587c7273d85c50288387099a6b Mon Sep 17 00:00:00 2001 From: Bartek Tofel Date: Mon, 16 Sep 2024 11:50:08 +0200 Subject: [PATCH] print changeset file content in GH comment --- .github/workflows/solidity-tracability.yml | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/.github/workflows/solidity-tracability.yml b/.github/workflows/solidity-tracability.yml index 6f2fc92193a..b9d138c78e3 100644 --- a/.github/workflows/solidity-tracability.yml +++ b/.github/workflows/solidity-tracability.yml @@ -135,6 +135,39 @@ jobs: env: GITHUB_TOKEN: ${{ steps.get-gh-token.outputs.access-token }} + - name: Read changeset file content + shell: bash + id: read-changeset-file + run: | + # we know there's only one file, because otherwise "Enforce Traceability" step would have failed + # Extract content after the last occurrence of '---' to avoid problems with GITHUB_OUTPUT + changesets_file_content=$(awk 'BEGIN {RS="---"; FS="\n";} {content=$0} END {print content}' "${{ needs.files-changed.outputs.changesets_files }}" | sed '/^$/d') + echo "changesets_file_content=$changesets_file_content" >> $GITHUB_OUTPUT + + - name: Find traceability comment in the PR + uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e # v3.0.0 + id: find-comment + with: + issue-number: ${{ github.event.pull_request.number }} + comment-author: 'github-actions[bot]' + body-includes: 'Solidity Review Jira issue' + + - name: Create or update traceability comment in the PR + uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0 + with: + comment-id: ${{ steps.find-comment.outputs.comment-id }} + issue-number: ${{ github.event.pull_request.number }} + body: | + ## Solidity Review Jira issue + Hey @${{ github.event.push && github.event.push.pusher && github.event.push.pusher.username || github.actor }}, we have linked this PR to a Jira issue for Solidity Review. + Please make sure that the linkage is correct and in a contrary case, please update the linkage manually in JIRA and replace Solidity Review issue in the changeset file, with the correct one. + + Below you can find current content of the (changeset)[${{ needs.files-changed.outputs.changesets_files }}] file: + ``` + ${{ steps.read-changeset-file.outputs.changesets_file_content }} + ``` + edit-mode: replace + - name: Collect Metrics id: collect-gha-metrics if: always()