Skip to content

Commit 3864762

Browse files
bors[bot]Bromeon
andauthored
Merge #259
259: CI workflow to notify API Docs automation r=Bromeon a=Bromeon Co-authored-by: Jan Haller <bromeon@gmail.com>
2 parents e27a69e + cf8e15b commit 3864762

File tree

2 files changed

+106
-0
lines changed

2 files changed

+106
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
MTFBQUZNN0NBMEQ4UVZLUzRxR0R2M19YVHRYMFR3amk1TlNrRTk5cWxiQWZWbzByVmxaVzBoak5UbHJvaENxUDVISU1aR09RNzcxMGNZSVpiZAo=

.github/workflows/update-docs.yml

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# This Source Code Form is subject to the terms of the Mozilla Public
2+
# License, v. 2.0. If a copy of the MPL was not distributed with this
3+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
4+
5+
name: Compile + Sync Docs
6+
7+
on:
8+
pull_request:
9+
types:
10+
- opened
11+
- reopened
12+
- closed
13+
- synchronize
14+
15+
push:
16+
branches:
17+
- master
18+
19+
20+
jobs:
21+
notify-docs:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: "Checkout"
25+
if: github.event_name == 'pull_request' && github.event.action != 'closed'
26+
uses: actions/checkout@v3
27+
28+
# This is just a sanity check to make sure that the follow-up docs generation doesn't break.
29+
# So we use the Rust version provided by the GitHub runners, which hopefully is >= MSRV.
30+
- name: "Compile"
31+
if: github.event_name == 'pull_request' && github.event.action != 'closed'
32+
run: cargo check -p godot $GDEXT_FEATURES
33+
34+
# Pushed to master: no PR-related information
35+
- name: "Construct JSON (for master)"
36+
if: github.ref == 'refs/heads/master'
37+
run: |
38+
payload=$(cat <<'HEREDOC'
39+
{
40+
"op": "put",
41+
"repo": "gdext",
42+
"num": "master",
43+
"commit-sha": "${{ github.sha }}",
44+
"date": "${{ github.event.head_commit.timestamp }}"
45+
}
46+
HEREDOC)
47+
echo "VAR=$payload"
48+
echo "GDEXT_JSON<<HEREDOC" >> $GITHUB_ENV
49+
echo "${payload}" >> $GITHUB_ENV
50+
echo "HEREDOC" >> $GITHUB_ENV
51+
52+
# Opened/reopened/updated PR: include PR author + title
53+
- name: "Construct JSON (for PR sync)"
54+
if: github.event_name == 'pull_request' && github.event.action != 'closed'
55+
run: |
56+
payload=$(cat <<'HEREDOC'
57+
{
58+
"op": "put",
59+
"repo": "gdext",
60+
"num": "${{ github.event.number }}",
61+
"commit-sha": "${{ github.event.pull_request.head.sha }}",
62+
"date": "${{ github.event.pull_request.updated_at }}",
63+
"pr-author": "${{ github.event.pull_request.user.login }}",
64+
"pr-title": "${{ github.event.pull_request.title }}"
65+
}
66+
HEREDOC)
67+
echo "VAR=$payload"
68+
echo "GDEXT_JSON<<HEREDOC" >> $GITHUB_ENV
69+
echo "${payload}" >> $GITHUB_ENV
70+
echo "HEREDOC" >> $GITHUB_ENV
71+
72+
# Closed/merged PR: no more PR-related information necessary, as it will be removed
73+
- name: "Construct JSON (for closed PR)"
74+
if: github.event_name == 'pull_request' && github.event.action == 'closed'
75+
run: |
76+
payload=$(cat <<'HEREDOC'
77+
{
78+
"op": "delete",
79+
"repo": "gdext",
80+
"num": "${{ github.event.number }}",
81+
"date": "${{ github.event.pull_request.updated_at }}"
82+
}
83+
HEREDOC)
84+
echo "VAR=$payload"
85+
echo "GDEXT_JSON<<HEREDOC" >> $GITHUB_ENV
86+
echo "${payload}" >> $GITHUB_ENV
87+
echo "HEREDOC" >> $GITHUB_ENV
88+
89+
- name: "Print payload"
90+
run: |
91+
echo "$GDEXT_JSON"
92+
93+
- name: "Prepare request"
94+
run: |
95+
token=$(cat .github/external-config/public-docs-token.txt | base64 -w0 -d)
96+
echo "DOCS_GENERATOR_TOKEN=github_pat_$token" >> $GITHUB_ENV
97+
98+
- name: "Notify doc workflow"
99+
uses: peter-evans/repository-dispatch@v2
100+
with:
101+
token: ${{ env.DOCS_GENERATOR_TOKEN }}
102+
repository: godot-rust/dispatch-forwarder
103+
event-type: 'Generate docs'
104+
client-payload: ${{ env.GDEXT_JSON }}
105+

0 commit comments

Comments
 (0)