-
-
Notifications
You must be signed in to change notification settings - Fork 144
66 lines (59 loc) · 2.09 KB
/
ci-pr-comments.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
name: Check Depgraph
on:
workflow_run:
workflows: ["CI"]
types:
- completed
permissions:
# Needed in order to leave comments on pull requests.
pull-requests: "write"
env:
CARGO_TERM_COLOR: always
jobs:
check-depgraph:
runs-on: ubuntu-latest
if: >
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'failure'
steps:
- name: Checkout Actions Repository
uses: actions/checkout@v3
- name: Download artifact
id: find-artifact
uses: actions/github-script@v6
with:
result-encoding: string
script: |
var artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{ github.event.workflow_run.id }},
});
var matchArtifacts = artifacts.data.artifacts.filter((artifact) => {
return artifact.name == "bad-depgraph"
});
if (matchArtifacts.length == 0) { return "false" }
var matchArtifact = matchArtifacts[0];
var download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
var fs = require('fs');
fs.writeFileSync('${{github.workspace}}/bad-depgraph.zip', Buffer.from(download.data));
return "true"
- name: Extract artifact
id: extract_artifact
if: ${{ steps.find-artifact.outputs.result == 'true' }}
run: |
unzip bad-depgraph.zip
echo "event_number=$(cat event-number)" >> "$GITHUB_OUTPUT"
- name: Create pull request comment
uses: marocchino/sticky-pull-request-comment@v2
if: ${{ steps.find-artifact.outputs.result == 'true' }}
with:
recreate: true
header: depgraph
path: pr-comment.txt
number: ${{ steps.extract_artifact.outputs.event_number }}