Repository navigation
181 lines (165 loc) · 6.37 KB
/
Copy pathdocs.yml
File metadata and controls
181 lines (165 loc) · 6.37 KB
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
174
175
176
177
178
179
180
181
name: Publish versioned documentation
on:
workflow_run:
workflows: [Continuous Integration]
types: [completed]
schedule:
- cron: '23 6 * * *'
workflow_dispatch:
inputs:
retry_failed:
description: Retry previously failed release documentation builds
type: boolean
default: false
permissions:
contents: read
concurrency:
group: pages
cancel-in-progress: false
jobs:
assemble:
if: >-
github.repository == 'connectbot/cbssh' &&
(github.event_name != 'workflow_run' ||
(github.event.workflow_run.event == 'push' &&
(github.event.workflow_run.head_branch == 'main' || startsWith(github.event.workflow_run.head_branch, 'v') || contains(github.event.workflow_run.head_branch, '.'))))
runs-on: ubuntu-latest
timeout-minutes: 180
permissions:
contents: write
actions: read
pages: read
outputs:
artifact_id: ${{ steps.upload.outputs.artifact_id }}
deferred: ${{ steps.admission.outputs.deferred }}
failures: ${{ steps.docs.outputs.failures }}
steps:
- name: Checkout source from main
uses: actions/checkout@v7.0.1
with:
ref: main
fetch-depth: 0
fetch-tags: true
- name: Check whether source CI is still running
id: admission
if: github.event_name == 'workflow_run'
env:
GH_TOKEN: ${{ github.token }}
run: |
source_commit=$(git rev-parse HEAD)
status=$(gh api --method GET "repos/$GITHUB_REPOSITORY/actions/workflows/ci.yml/runs" \
-f "head_sha=$source_commit" -f event=push -F per_page=1 \
--jq '.workflow_runs[0].status // empty')
if [[ -n "$status" && "$status" != completed ]]; then
echo 'deferred=true' >> "$GITHUB_OUTPUT"
echo "Documentation for $source_commit is deferred until push CI completes (current status $status)." >> "$GITHUB_STEP_SUMMARY"
fi
- name: Set up JDK
if: steps.admission.outputs.deferred != 'true'
uses: actions/setup-java@v6.3.0
with:
distribution: zulu
java-version: '17'
- name: Set up Gradle
if: steps.admission.outputs.deferred != 'true'
uses: gradle/actions/setup-gradle@v6.4.1
with:
validate-wrappers: true
dependency-graph: disabled
- name: Reconcile and save documentation archive
id: docs
if: steps.admission.outputs.deferred != 'true'
uses: connectbot/actions/docs@main
env:
GH_TOKEN: ${{ github.token }}
with:
retry-failed: ${{ inputs.retry_failed || false }}
publish: 'true'
require-ci: 'true'
- name: Preserve build logs
if: always() && steps.admission.outputs.deferred != 'true'
uses: actions/upload-artifact@v7.0.2
with:
name: documentation-build-logs
path: ${{ runner.temp }}/docs-logs
if-no-files-found: ignore
- name: Report source CI status
if: steps.docs.outputs.failures != '0' && steps.docs.outcome == 'success'
env:
GH_TOKEN: ${{ github.token }}
run: |
source_commit=$(git rev-parse HEAD)
{
printf '\n### Push CI for main at %s\n\n' "$source_commit"
if run=$(gh api --method GET "repos/$GITHUB_REPOSITORY/actions/workflows/ci.yml/runs" \
-f "head_sha=$source_commit" -f event=push -F per_page=1 \
--jq '.workflow_runs[0].id // empty'); then
if [[ -n "$run" ]]; then
printf '[CI run](%s/%s/actions/runs/%s)\n\n' "$GITHUB_SERVER_URL" "$GITHUB_REPOSITORY" "$run"
gh api --paginate "repos/$GITHUB_REPOSITORY/actions/runs/$run/jobs?per_page=100" \
--jq '.jobs[] | "- \(.name) — \(.conclusion // .status)" + ([.steps[]? | select(.conclusion == "failure") | .name] | if length > 0 then " (" + join(", ") + ")" else "" end)' \
|| echo 'Could not retrieve CI job results.'
else
echo 'No push CI run was found for this commit.'
fi
else
echo 'Could not retrieve push CI status.'
fi
} >> "$GITHUB_STEP_SUMMARY"
- name: Set up Pages
if: steps.docs.outputs.ready == 'true'
uses: actions/configure-pages@v6.0.0
- name: Upload complete site
if: steps.docs.outputs.ready == 'true'
id: upload
uses: actions/upload-pages-artifact@v5.0.0
with:
path: ${{ runner.temp }}/docs-site
- name: Report unavailable site
if: steps.admission.outputs.deferred != 'true' && steps.docs.outputs.ready != 'true'
run: |
echo '::error::No documentation site is ready. See the job summary and build logs.'
exit 1
deploy:
needs: assemble
if: needs.assemble.outputs.deferred != 'true'
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
actions: read
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Wait for Pages artifact
env:
GH_TOKEN: ${{ github.token }}
ARTIFACT_ID: ${{ needs.assemble.outputs.artifact_id }}
run: |
if [[ ! "$ARTIFACT_ID" =~ ^[0-9]+$ ]]; then
echo '::error::Pages upload did not return an artifact ID.'
exit 1
fi
for delay in 1 2 4 8 16 0; do
if timeout 5s gh api --paginate "repos/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID/artifacts?name=github-pages&per_page=100" \
--jq '.artifacts[] | select(.expired == false) | .id' | grep -Fx "$ARTIFACT_ID"; then
exit 0
fi
if [[ "$delay" != 0 ]]; then sleep "$delay"; fi
done
echo "::error::Pages artifact $ARTIFACT_ID is unavailable in run $GITHUB_RUN_ID."
exit 1
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v5.0.1
report:
needs: [assemble, deploy]
if: needs.assemble.result == 'success' && needs.assemble.outputs.failures != '0'
runs-on: ubuntu-latest
steps:
- name: Report incomplete documentation
run: |
echo '::error::Some documentation versions are incomplete. See the assembly job summary and build logs.'
exit 1