@@ -20,6 +20,8 @@ run-name: "Build and Publish (${{ inputs.slicer_repository }}@${{ inputs.slicer_
20
20
permissions :
21
21
# Needed in the publish step to update gh-pages branch
22
22
contents : write
23
+ # Needed to update the status associated with the Slicer commit
24
+ statuses : write
23
25
24
26
jobs :
25
27
build-and-publish :
42
44
echo "::error ::Invalid skip value 'preview'. Supported values are 'true' or 'false'"
43
45
exit 1
44
46
fi
47
+
48
+ if [[ $preview == "false" ]]; then
49
+ publish_repository="apidocs.slicer.org"
50
+ else
51
+ publish_repository="preview.apidocs.slicer.org"
52
+ fi
53
+ echo "publish_repository [$publish_repository]"
54
+
45
55
echo "slicer_repository=$slicer_repository" >> $GITHUB_OUTPUT
46
56
echo "slicer_ref=$slicer_ref" >> $GITHUB_OUTPUT
47
57
echo "preview=$preview" >> $GITHUB_OUTPUT
58
+ echo "publish_repository=$publish_repository" >> $GITHUB_OUTPUT
48
59
env :
49
60
EVENT_NAME : ${{ github.event_name }}
50
61
54
65
path : Slicer
55
66
ref : ${{ steps.collect_inputs.outputs.slicer_ref }}
56
67
68
+ - name : Slicer Checkout Details
69
+ id : slicer-checkout-details
70
+ run : |
71
+ cd Slicer
72
+ sha=$(git rev-parse HEAD)
73
+ echo "sha [$sha]"
74
+ echo "sha=$sha" >> $GITHUB_OUTPUT
75
+
57
76
- uses : actions/create-github-app-token@c1a285145b9d317df6ced56c09f525b5c2b6f755 # v1.11.1
58
77
id : app-token
59
78
with :
63
82
repositories : |
64
83
apidocs.slicer.org
65
84
preview.apidocs.slicer.org
85
+ Slicer
86
+ Slicer-CI-Testing
87
+
88
+ - name : Set GitHub status to 'pending'
89
+ run : |
90
+ gh api \
91
+ --method POST \
92
+ -H "Accept: application/vnd.github+json" \
93
+ /repos/${SLICER_REPO_NAME}/statuses/${SLICER_REPO_REVISION} \
94
+ -f state='pending' \
95
+ -f target_url='https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}' \
96
+ -f description='API documentation is being generated' \
97
+ -f context='slicer/apidocs'
98
+ env :
99
+ GH_TOKEN : ${{ steps.app-token.outputs.token }}
100
+ SLICER_REPO_NAME : ${{ steps.collect_inputs.outputs.slicer_repository }}
101
+ SLICER_REPO_REVISION : ${{ steps.slicer-checkout-details.outputs.sha }}
66
102
67
103
- name : Determine if ref is branch or tag
68
104
id : determine
@@ -193,7 +229,7 @@ jobs:
193
229
194
230
- uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
195
231
with :
196
- repository : Slicer/${{ toJSON( steps.collect_inputs.outputs.preview) && 'preview.apidocs.slicer.org' || 'apidocs.slicer.org' }}
232
+ repository : Slicer/${{ steps.collect_inputs.outputs.publish_repository }}
197
233
ref : gh-pages
198
234
path : gh-pages
199
235
token : ${{ steps.app-token.outputs.token }}
@@ -236,3 +272,43 @@ jobs:
236
272
SLICER_REPO_BRANCH : ${{ steps.determine.outputs.slicer_repo_branch }}
237
273
SLICER_REPO_TAG : ${{ steps.determine.outputs.slicer_repo_tag }}
238
274
275
+ - name : Set GitHub status to 'success'
276
+ run : |
277
+ target_url_path="$SLICER_REPO_BRANCH"
278
+ if [[ "$SLICER_REPO_TAG" != "" ]]; then
279
+ target_url_path=$(echo "$SLICER_REPO_TAG" | grep -oE '^v[0-9]+\.[0-9]+')
280
+ fi
281
+ echo "target_url_path [$target_url_path]"
282
+ target_url="https://${{ steps.collect_inputs.outputs.publish_repository }}/${target_url_path}"
283
+ echo "target_url [$target_url]"
284
+ gh api \
285
+ --method POST \
286
+ -H "Accept: application/vnd.github+json" \
287
+ /repos/${SLICER_REPO_NAME}/statuses/${SLICER_REPO_REVISION} \
288
+ -f state='success' \
289
+ -f target_url="$target_url" \
290
+ -f description='API documentation published' \
291
+ -f context='slicer/apidocs'
292
+ env :
293
+ GH_TOKEN : ${{ steps.app-token.outputs.token }}
294
+ SLICER_REPO_NAME : ${{ steps.collect_inputs.outputs.slicer_repository }}
295
+ SLICER_REPO_REVISION : ${{ steps.slicer-checkout-details.outputs.sha }}
296
+ SLICER_REPO_BRANCH : ${{ steps.determine.outputs.slicer_repo_branch }}
297
+ SLICER_REPO_TAG : ${{ steps.determine.outputs.slicer_repo_tag }}
298
+
299
+ - name : Set GitHub status to 'failure'
300
+ if : ${{ failure() }}
301
+ run : |
302
+ gh api \
303
+ --method POST \
304
+ -H "Accept: application/vnd.github+json" \
305
+ /repos/${SLICER_REPO_NAME}/statuses/${SLICER_REPO_REVISION} \
306
+ -f state='failure' \
307
+ -f target_url='https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}' \
308
+ -f description='API documentation failed to be generated' \
309
+ -f context='slicer/apidocs'
310
+ env :
311
+ GH_TOKEN : ${{ steps.app-token.outputs.token }}
312
+ SLICER_REPO_NAME : ${{ steps.collect_inputs.outputs.slicer_repository }}
313
+ SLICER_REPO_REVISION : ${{ steps.slicer-checkout-details.outputs.sha }}
314
+
0 commit comments