-
Notifications
You must be signed in to change notification settings - Fork 141
63 lines (56 loc) · 2.41 KB
/
annotate.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
name: Annotate pull request with regression summaries
# Takes a regression summary from a workflow run and annotates the pull request with it
# The pull request number is taken from the first line of the summary.txt file.
# The summary file is in an artifact called regression_summary associated
# with the workflow run that triggered this workflow.
# based on https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#using-data-from-the-triggering-workflow
on:
workflow_run:
workflows:
- Continuous Integration
types:
- completed
run-name: Annotate "${{ github.event.workflow_run.display_title }}"
jobs:
on-success:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'pull_request' }}
steps:
- run: echo 'The triggering workflow passed'
- name: 'Download regression_summary artifact'
uses: actions/github-script@v6
with:
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 == "regression_summary"
})[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}/regression_summary.zip`, Buffer.from(download.data));
- name: 'Unzip artifact'
run: unzip regression_summary.zip
- name: 'Get pull request number'
run: |
echo "PR_NUMBER=$( head -n 1 summary.txt )" >> $GITHUB_ENV
# remove the first line from the file
sed -i '1d' summary.txt
- name: Write summary to pull request as a comment
uses: thollander/actions-comment-pull-request@v2
with:
filePath: summary.txt
pr_number: ${{ env.PR_NUMBER }}
- name: Report the github.event.workflow_run as json
if: ${{ failure() }}
run: echo $JSON
env:
JSON: ${{ toJson(github.event.workflow_run) }}