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 20, 2024
1 parent cb74ee2 commit 49fa065
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/link-PR-artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
run_id: context.payload.workflow_run.id,
});
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
return artifact.name == "pr_number"
return artifact.name == "PR_ARTIFACTS"
})[0];
let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
Expand All @@ -29,18 +29,18 @@ jobs:
archive_format: 'zip',
});
let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/pr_number.zip`, Buffer.from(download.data));
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/PR_ARTIFACTS.zip`, Buffer.from(download.data));
- name: 'Unzip artifact'
run: unzip pr_number.zip
run: unzip PR_ARTIFACTS.zip

- 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('./pr_number'));
let issue_number = Number(fs.readFileSync('./PR_ARTIFACTS'));
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
Expand Down
13 changes: 4 additions & 9 deletions .github/workflows/upload-PR-artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,8 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Save PR number
env:
PR_NUMBER: ${{ github.event.number }}
run: |
mkdir -p ./pr
echo $PR_NUMBER > ./pr/pr_number
- uses: actions/upload-artifact@v4
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: pr_number
path: pr/
name: PR_ARTIFACTS
path: obj/*.hex

0 comments on commit 49fa065

Please sign in to comment.