Skip to content

Commit

Permalink
test: comment via artifact
Browse files Browse the repository at this point in the history
Signed-off-by: Robert Waffen <rwaffen@gmail.com>
  • Loading branch information
rwaffen committed Aug 30, 2024
1 parent c3c3820 commit 3f4050a
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 5 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,19 @@ jobs:
name: Test suite
steps:
- run: echo Test suite completed

save-pr-number:
runs-on: ubuntu-latest
name: Save PR number
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
with:
name: pr_number
path: pr/
42 changes: 37 additions & 5 deletions .github/workflows/docker_scout.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
uses: actions/checkout@v4

- name: Build local container
id: build_test_container
uses: docker/build-push-action@v6
with:
tags: 'ci/test:${{ matrix.puppet_release }}'
Expand Down Expand Up @@ -65,10 +66,41 @@ jobs:
image: 'local://ci/test:${{ matrix.puppet_release }}'
to: 'ghcr.io/voxpupuli/test:${{ matrix.puppet_release }}-main'
summary: true
keep-previous-comments: true

- name: Upload SARIF result
id: upload-sarif
uses: github/codeql-action/upload-sarif@v3
- name: 'Download artifact'
uses: actions/github-script@v6
with:
sarif_file: sarif.output.${{ matrix.puppet_release }}.${{ github.sha }}.json
script: |
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
return artifact.name == "pr_number"
})[0];
let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/pr_number.zip`, Buffer.from(download.data));
- name: 'Unzip artifact'
run: unzip pr_number.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'));
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue_number,
body: 'See Docker Scout results [here](${{ github.event.workflow.html_url }}).'
});

0 comments on commit 3f4050a

Please sign in to comment.