forked from erlang/otp
-
Notifications
You must be signed in to change notification settings - Fork 0
126 lines (113 loc) · 4.38 KB
/
pr-comment.yaml
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
name: Update PR details
# read-write repo token
# access to secrets
on:
workflow_run:
workflows: ["Build and check Erlang/OTP"]
types:
- requested
- completed
# Limit concurrency so that we don't get any races between parallel actions
concurrency: pr-comment
jobs:
pr-number:
runs-on: ubuntu-20.04
if: github.repository == 'erlang/otp'
outputs:
result: ${{ steps.pr-number.outputs.result }}
steps:
- uses: actions/checkout@v2
- name: Fetch PR number
id: pr-number
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
run: |
git clone https://github.com/talentdeficit/jsx
(cd jsx && rebar3 compile)
.github/scripts/get-pr-number.es erlang/otp \
"${{ github.event.workflow_run.head_sha }}"
starting-tests:
runs-on: ubuntu-latest
needs: pr-number
if: github.event.action == 'requested' && needs.pr-number.outputs.result != ''
steps:
- uses: actions/checkout@v2
## We create an initial comment with some useful help to the user
- uses: actions/[email protected]
with:
script: |
const script = require('./.github/scripts/pr-comment.js');
return await script({github, context, state: 'starting',
pr_number: ${{ needs.pr-number.outputs.result }} });
finished-tests:
runs-on: ubuntu-20.04
needs: pr-number
## Limit concurrency so that only one job deploys to erlang.github.io
concurrency: erlang.github.io-deploy
if: >-
github.event.action == 'completed' &&
needs.pr-number.outputs.result != '' &&
github.event.workflow_run.conclusion != 'skipped'
steps:
- uses: actions/checkout@v2
- name: Download and Extract Artifacts
id: extract
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
run: |
mkdir -p artifacts && cd artifacts
artifacts_url=${{ github.event.workflow_run.artifacts_url }}
gh api "$artifacts_url" --paginate -q '.artifacts[] | [.name, .archive_download_url] | @tsv' | while read artifact
do
IFS=$'\t' read name url <<< "$artifact"
if [ "$name" = "Unit Test Results" ] || [ "$name" = "Event File" ]; then
gh api $url > "$name.zip"
unzip -d "$name" "$name.zip"
fi
done
if [ -d "Unit Test Results" ]; then
echo "HAS_TEST_ARTIFACTS=true" >> $GITHUB_OUTPUT
else
echo "HAS_TEST_ARTIFACTS=false" >> $GITHUB_OUTPUT
fi
- uses: actions/checkout@v2
with:
token: ${{ secrets.ERLANG_TOKEN }}
repository: 'erlang/erlang.github.io'
path: erlang.github.io
- name: Publish CT Test Results
uses: EnricoMi/publish-unit-test-result-action@v1
if: steps.extract.outputs.HAS_TEST_ARTIFACTS == 'true'
with:
commit: ${{ github.event.workflow_run.head_sha }}
event_file: artifacts/Event File/event.json
event_name: ${{ github.event.workflow_run.event }}
check_name: "CT Test Results"
files: "artifacts/**/*.xml"
- name: Upload PR to github pages
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
run: |
git clone https://github.com/talentdeficit/jsx
(cd jsx && rebar3 compile)
mkdir -p "${GITHUB_WORKSPACE}/erlang.github.io/prs/"
.github/scripts/sync-github-prs.es erlang/otp \
"${GITHUB_WORKSPACE}/erlang.github.io/prs/" \
"${{ needs.pr-number.outputs.result }}"
- name: Deploy to github pages 🚀
uses: JamesIves/[email protected]
with:
token: ${{ secrets.ERLANG_TOKEN }}
branch: master # The branch the action should deploy to.
folder: erlang.github.io # The folder the action should deploy.
repository-name: erlang/erlang.github.io
single-commit: true
## Append some usefull links and tips to the test results posted by
## Publish CT Test Results
- uses: actions/[email protected]
if: always()
with:
script: |
const script = require('./.github/scripts/pr-comment.js');
return await script({github, context, state: 'finished',
pr_number: ${{ needs.pr-number.outputs.result }} });