forked from KeYProject/key
-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (80 loc) · 3.5 KB
/
artiweb.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
85
86
87
88
name: Artiweb 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@v7
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 testArtifact = allArtifacts.data.artifacts.find((artifact) => {
return artifact.name == "test-results"
});
if (testArtifact !== undefined) {
core.info("Found test-results artifact id: " + testArtifact.id);
core.setOutput("test-artifact-id", testArtifact.id);
} else {
core.info("Artifact test-results was not found");
}
const numberArtifact = allArtifacts.data.artifacts.find((artifact) => {
return artifact.name == "pr-number"
});
if (numberArtifact !== undefined) {
core.info("Found pr-number artifact id: " + numberArtifact.id);
let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: numberArtifact.id,
archive_format: 'zip',
});
let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/pr_number.zip`, Buffer.from(download.data));
} else {
core.setFailed("Artifact pr-number was not found");
}
- name: 'Unzip artifact'
run: unzip pr_number.zip
- name: 'Read pr number'
id: rpn
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
let fs = require('fs');
let issue_number_text = fs.readFileSync('./pr_number', 'utf8');
core.info("Found pr number \"" + issue_number_text + "\"");
core.setOutput("pr-number", issue_number_text === "" ? "" : Number(issue_number_text));
- name: Find Comment
if: ${{ steps.rpn.outputs.pr-number != '' }}
uses: peter-evans/find-comment@v3
id: fc
with:
issue-number: ${{ steps.rpn.outputs.pr-number }}
comment-author: 'github-actions[bot]'
body-includes: Artiweb
- name: Create or update comment
if: ${{ steps.rpn.outputs.pr-number != '' }}
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ steps.rpn.outputs.pr-number }}
body: |
Thank you for your contribution.
The test artifacts are available on [Artiweb](e8e3f762-a110-4e21-bc41-cacb5f3a3a50.ka.bw-cloud-instance.org/${{steps.rpn.outputs.pr-number}}/).
The newest artifact is [here](e8e3f762-a110-4e21-bc41-cacb5f3a3a50.ka.bw-cloud-instance.org/${{steps.rpn.outputs.pr-number}}/${{steps.da.outputs.test-artifact-id}}/).
edit-mode: replace