Skip to content

Commit

Permalink
Github Actions - Link Artifacts in PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
nerdCopter committed Feb 21, 2024
1 parent 3d370c8 commit b9ba6e4
Showing 1 changed file with 32 additions and 23 deletions.
55 changes: 32 additions & 23 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/')
Expand Down

0 comments on commit b9ba6e4

Please sign in to comment.