-
Notifications
You must be signed in to change notification settings - Fork 45
173 lines (162 loc) · 5.73 KB
/
deploy.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
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
name: Deploy
on:
workflow_dispatch:
push:
branches:
- main
pull_request:
merge_group:
jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
test: [""]
stage: ["commit", "push"]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: pre-commit checks
shell: bash
run: |
set -o pipefail
sudo apt-get update
sudo apt-get install -y --no-install-recommends webp pipx
pipx ensurepath
pipx install pre-commit
CI_FAIL=false
EXTRA_ARGS=("--all-files")
if [ "${{ github.event_name }}" == "push" ]
then
if [ "${{ github.event.created }}" != "true" ]
then
git fetch origin ${{ github.event.before }}:old_head
FROM_REF="${{ github.event.before }}"
TO_REF="${{ github.event.after }}"
EXTRA_ARGS=("--from-ref" "$FROM_REF" "--to-ref" "$TO_REF")
fi
elif [ "${{ github.event_name }}" == "pull_request" ]
then
FROM_REF="${{ github.event.pull_request.base.sha }}"
TO_REF="${{ github.event.pull_request.head.sha }}"
EXTRA_ARGS=("--from-ref" "$FROM_REF" "--to-ref" "$TO_REF")
elif [ "${{ github.event_name }}" == "merge_group" ]
then
git fetch origin ${{ github.event.merge_group.base_sha }}:old_head
FROM_REF="${{ github.event.merge_group.base_sha }}"
TO_REF="${{ github.event.merge_group.head_sha }}"
EXTRA_ARGS=("--from-ref" "$FROM_REF" "--to-ref" "$TO_REF")
fi
EXTRA_ARGS+=("--hook-stage" "${{ matrix.stage }}" "${{ matrix.test }}")
if ! pre-commit run --show-diff-on-failure "${EXTRA_ARGS[@]}" 2>&1 | tee /tmp/ci_result.log
then
CI_FAIL=true
fi
if $CI_FAIL
then
echo ''
echo '=== Issue detected! ==='
echo 'Suggest changes are listed above.'
echo 'Please install pre-commit and run `pre-commit run --all-files` to fix it.'
echo 'Strongly recommended to run `pre-commit install` to catch issues before pushing.'
echo 'You can learn more abour pre-commit from https://pre-commit.com/'
exit 1
fi
test-optional:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
test: ["check-external-links", "gitown"]
stage: ["manual"]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: pre-commit check-external-links
shell: bash
run: |
set -o pipefail
sudo apt-get update
sudo apt-get install -y --no-install-recommends webp pipx
pipx ensurepath
pipx install pre-commit
CI_FAIL=false
EXTRA_ARGS=("--all-files")
if [ "${{ github.event_name }}" == "push" ]
then
if [ "${{ github.event.created }}" != "true" ]
then
git fetch origin ${{ github.event.before }}:old_head
FROM_REF="${{ github.event.before }}"
TO_REF="${{ github.event.after }}"
EXTRA_ARGS=("--from-ref" "$FROM_REF" "--to-ref" "$TO_REF")
fi
elif [ "${{ github.event_name }}" == "pull_request" ]
then
FROM_REF="${{ github.event.pull_request.base.sha }}"
TO_REF="${{ github.event.pull_request.head.sha }}"
EXTRA_ARGS=("--from-ref" "$FROM_REF" "--to-ref" "$TO_REF")
elif [ "${{ github.event_name }}" == "merge_group" ]
then
git fetch origin ${{ github.event.merge_group.base_sha }}:old_head
FROM_REF="${{ github.event.merge_group.base_sha }}"
TO_REF="${{ github.event.merge_group.head_sha }}"
EXTRA_ARGS=("--from-ref" "$FROM_REF" "--to-ref" "$TO_REF")
fi
EXTRA_ARGS+=("--hook-stage" "${{ matrix.stage }}" "${{ matrix.test }}")
if ! pre-commit run --show-diff-on-failure "${EXTRA_ARGS[@]}" 2>&1 | tee /tmp/ci_result.log
then
CI_FAIL=true
fi
if $CI_FAIL
then
echo ''
echo '=== Issue detected! ==='
echo 'Suggest changes are listed above.'
echo 'Please install pre-commit and run `pre-commit run --all-files` to fix it.'
echo 'Strongly recommended to run `pre-commit install` to catch issues before pushing.'
echo 'You can learn more abour pre-commit from https://pre-commit.com/'
exit 1
fi
build:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
steps:
- name: Checkout template
uses: actions/checkout@v4
with:
token: "${{ secrets.PRIVATE_REPO_TOKEN }}"
repository: "radxa-docs/docs-template"
- name: Checkout contents
uses: actions/checkout@v4
with:
path: "contents"
- name: Build
run: |
yarn install
yarn build
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
# Upload entire repository
path: "./build"
deploy:
needs: build
if: github.event_name != 'pull_request' && github.event_name != 'merge_group' && github.ref_name == 'main'
runs-on: ubuntu-latest
permissions:
id-token: write
pages: write
steps:
- name: Setup Pages
id: setup-pages
uses: actions/configure-pages@v5
continue-on-error: true
- name: Deploy to GitHub Pages
uses: actions/deploy-pages@v4
if: steps.setup-pages.outcome == 'success'