-
-
Notifications
You must be signed in to change notification settings - Fork 134
84 lines (75 loc) · 2.95 KB
/
public-api.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
name: Cargo-public-api comment
on:
workflow_run:
workflows: [Tests]
types:
- completed
# taken from https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#using-data-from-the-triggering-workflow
jobs:
comment:
runs-on: ubuntu-latest
steps:
- name: 'Download artifact'
id: da
uses: actions/github-script@v6
with:
script: |
if (context.payload.workflow_run === undefined) {
core.setFailed("No workflow run found");
}
const allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
const theArtifact = allArtifacts.data.artifacts.find((artifact) => {
return artifact.name == "public-api"
});
if (theArtifact !== undefined) {
core.info("Found pr-number artifact id: " + theArtifact.id);
let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: theArtifact.id,
archive_format: 'zip',
});
let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/public_api.zip`, Buffer.from(download.data));
} else {
core.setFailed("Artifact public-api was not found");
}
- name: 'Unzip artifact'
run: unzip public_api.zip
- name: 'Read artifact'
id: ra
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
let fs = require('fs');
let issue_number_text = fs.readFileSync('./pr_number', 'uft8');
core.info("Found pr number \"" + issue_number_text + "\"");
core.setOutput("pr-number", issue_number_text === "" ? "" : Number(issue_number_text));
let diff = fs.readFileSync('./diff', 'uft8');
core.setOutput("diff", diff);
- name: Find Comment
uses: peter-evans/find-comment@v1
id: fc
with:
issue-number: ${{ steps.ra.outputs.pr-number }}
comment-author: "github-actions[bot]"
body-includes: Removed items from the public API
- name: Create comment
if: steps.fc.outputs.comment-id == ''
uses: peter-evans/create-or-update-comment@v1
with:
issue-number: ${{ steps.ra.outputs.pr-number }}
body: |
${{ steps.ra.outputs.diff }}
- name: Update comment
if: steps.fc.outputs.comment-id != ''
uses: peter-evans/create-or-update-comment@v1
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
body: |
${{ steps.ra.outputs.diff }}