From b9ba6e45f79d41b17b09d79781b163c8de2ed80e Mon Sep 17 00:00:00 2001 From: nerdCopter <56646290+nerdCopter@users.noreply.github.com> Date: Wed, 21 Feb 2024 11:01:29 -0600 Subject: [PATCH] Github Actions - Link Artifacts in PR comments --- .github/workflows/build.yml | 55 +++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 23 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8197cb4818..a76212da1d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -140,31 +140,40 @@ jobs: artifacts: if: github.event_name == 'pull_request' needs: build + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + runs-on: ubuntu-latest - # Hide existing/outdated artifacts links - - name: Hide artifacts links from comments. - uses: int128/hide-comment-action@v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} - authors: "github-actions" - contains: "Compiled HEX from this Pull-Request. WARNING: No warranty or guarantee of any kind. Test/Fly at your own risk!" - continue-on-error: true + - name: download artifacts + uses: actions/download-artifact@v2 + with: + name: ${{ env.ARTIFACT_NAME }} + continue-on-error: false - # Add artifacts links to comments - - name: 'Comment on PR' - uses: actions/github-script@v6 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - let fs = require('fs'); - let issue_number = Number(fs.readFileSync(`./${{ env.ARTIFACT_NAME }}`)); - await github.rest.issues.createComment({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: issue_number, - body: "Compiled HEX from this Pull-Request. WARNING: No warranty or guarantee of any kind. Test/Fly at your own risk!" - }); - continue-on-error: true + # Hide existing/outdated artifacts links + - name: Hide artifacts links from comments. + uses: int128/hide-comment-action@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + authors: "github-actions" + contains: "Compiled HEX from this Pull-Request. WARNING: No warranty or guarantee of any kind. Test/Fly at your own risk!" + continue-on-error: true + + # Add artifacts links to comments + - name: 'Comment on PR' + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + let fs = require('fs'); + let issue_number = Number(fs.readFileSync(`./${{ env.ARTIFACT_NAME }}`)); + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issue_number, + body: "Compiled HEX from this Pull-Request. WARNING: No warranty or guarantee of any kind. Test/Fly at your own risk!" + }); + continue-on-error: true releases: if: startsWith(github.ref, 'refs/tags/')