-
Notifications
You must be signed in to change notification settings - Fork 3
157 lines (129 loc) · 5.38 KB
/
build-website.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
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# Copyright (c) godot-rust; Bromeon and contributors.
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
name: 'Deploy website'
on:
push:
branches: [master]
pull_request:
repository_dispatch:
types: ['Deploy docs']
env:
ZOLA_VERSION: 0.19.2
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: write # for mutex branch
pages: write
id-token: write
jobs:
check-website:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- name: "Checkout"
uses: actions/checkout@v4
- name: "Build website"
uses: shalzz/[email protected]
env:
BUILD_DIR: website
TOKEN: fake-token
BUILD_ONLY: true
deploy-website:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
steps:
- name: "Workflow triggered by push to master"
if: github.event_name == 'push'
run: echo "Triggered by commit SHA ${{ github.sha }}"
- name: "Workflow triggered by docs (${{ github.event.client_payload.op }} ${{ github.event.client_payload.repo }}/${{ github.event.client_payload.num }})"
if: github.event_name == 'repository_dispatch'
env:
JSON: ${{ toJson(github.event.client_payload) }}
run: echo "$JSON"
- name: "Wait for concurrent workflows to finish..."
uses: ben-z/[email protected]
with:
branch: ci-mutex-website
- name: "Checkout"
uses: actions/checkout@v4
# Note: if this is run the first time, this job fails because there is no doc-output branch.
# Easy enough to fix by deploying docs for both masters.
- name: "Fetch references to doc pages"
run: |
git fetch
git restore --source origin/doc-output website-docs-md
mv website-docs-md/* website/content/docs/
rm -r website-docs-md
# - name: "Build and deploy Zola"
# uses: shalzz/zola-deploy-action@master
# env:
# PAGES_BRANCH: gh-pages-prepared
# BUILD_DIR: website
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: "Install Zola ${{ env.ZOLA_VERSION }}"
run: |
wget -q -O - "https://github.com/getzola/zola/releases/download/v$ZOLA_VERSION/zola-v${ZOLA_VERSION}-x86_64-unknown-linux-gnu.tar.gz" \
| tar xzf - -C /usr/local/bin
- name: "Build Zola website"
working-directory: website
run: zola build
- name: "Integrate docs (triggered by push), push to gh-pages"
if: github.event_name == 'push'
run: |
bash documentation/fetch-website-docs.sh || {
echo "::warning::Could not fetch documentation"
}
- name: "Integrate docs (triggered by repo-dispatch)"
if: github.event_name == 'repository_dispatch'
env:
REPO: '${{ github.event.client_payload.repo }}'
NUM: '${{ github.event.client_payload.num }}'
run: |
bash documentation/fetch-website-docs.sh "$REPO" "$NUM"
- name: "Upload Pages artifact"
uses: actions/upload-pages-artifact@v3
with:
path: website/public
- name: "Deploy to GitHub Pages"
uses: actions/deploy-pages@v4
- name: "Comment on GitHub PR"
if: github.event_name == 'repository_dispatch' && github.event.client_payload.put_status == 'Create' && github.event.client_payload.num != 'master'
run: |
url="${{ github.event.client_payload.docs_full_url }}"
repo="${{ github.event.client_payload.repo }}"
num="${{ github.event.client_payload.num }}"
body="API docs are being generated and will be shortly available at: $url"
echo "cURL to https://api.github.com/repos/godot-rust/$repo/issues/$num/comments"
echo "Body: $body"
curl -L \
--fail-with-body \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.DOCS_COMMENTER_PAT }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-d "{\"body\":\"$body\"}" \
https://api.github.com/repos/godot-rust/$repo/issues/$num/comments
license-guard:
# not on repo dispatch
if: github.event_name != 'repository_dispatch'
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: "Check license headers"
uses: apache/skywalking-eyes/[email protected]
with:
# log: debug # optional: set the log level. The default value is `info`.
config: .github/external-config/licenserc.yml
# token: # optional: the token that license eye uses when it needs to comment on the pull request.
# Set to empty ("") to disable commenting on pull request. The default value is ${{ github.token }}
# mode: # optional: Which mode License-Eye should be run in. Choices are `check` or `fix`. The default value is `check`.
mode: check
- name: "Commit changes"
uses: EndBug/add-and-commit@v9
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
author_name: 'Godot-Rust Automation'
author_email: '[email protected]'
message: 'Auto-apply license headers'