Skip to content

Commit 91d1eb5

Browse files
committed
Add doc-publish-pdf.yml
1 parent b28e820 commit 91d1eb5

File tree

2 files changed

+93
-69
lines changed

2 files changed

+93
-69
lines changed

.github/workflows/doc-publish-pdf.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: Publish documentation
2+
3+
on:
4+
workflow_run:
5+
workflows: "Build documentation (PDF)"
6+
types:
7+
- completed
8+
9+
permissions:
10+
statuses: write
11+
checks: write
12+
pull-requests: write
13+
14+
15+
# This workflow runs after doc-build-pdf workflow, taking the
16+
# artifact livedoc and deploying it to a netlify site.
17+
#
18+
# event (triggered doc-build) URL (of the doc deployed to NETLIFY_SITE)
19+
# --------------------------- ---------------------------------
20+
# on push tag https://doc-release--NETLIFY_SITE
21+
#
22+
# where NETLIFY_SITE is presently sagemath.netlify.app for repo sagemath/sage.
23+
#
24+
# This workflow runs only if secrets NETLIFY_AUTH_TOKEN and NETLIFY_SITE_ID are set.
25+
26+
jobs:
27+
publish-live-doc:
28+
runs-on: ubuntu-latest
29+
if: github.event.workflow_run.conclusion == 'success'
30+
env:
31+
CAN_DEPLOY: ${{ secrets.NETLIFY_AUTH_TOKEN != '' && secrets.NETLIFY_SITE_ID != '' }}
32+
steps:
33+
- name: Get information about workflow origin
34+
uses: potiuk/get-workflow-origin@v1_5
35+
id: source-run-info
36+
with:
37+
token: ${{ secrets.GITHUB_TOKEN }}
38+
sourceRunId: ${{ github.event.workflow_run.id }}
39+
if: env.CAN_DEPLOY == 'true'
40+
41+
- name: Download live doc
42+
id: download-doc
43+
uses: actions/download-artifact@v4
44+
with:
45+
name: livedoc
46+
github-token: ${{ secrets.GITHUB_TOKEN }}
47+
repository: ${{ github.repository }}
48+
run-id: ${{ github.event.workflow_run.id }}
49+
# if the doc was built for tag push (targetBranch contains the tag)
50+
if: steps.source-run-info.outputs.sourceEvent == 'push' && steps.source-run-info.outputs.targetBranch != 'develop'
51+
52+
- name: Extract live doc
53+
run: unzip livedoc.zip -d livedoc
54+
if: steps.download-doc.outcome == 'success'
55+
56+
- name: Create _headers file for permissive CORS
57+
run: |
58+
cat <<EOF > livedoc/livedoc/_headers
59+
/*
60+
Access-Control-Allow-Origin: *
61+
Access-Control-Allow-Methods: GET
62+
Access-Control-Allow-Headers: Content-Type
63+
EOF
64+
if: steps.download-doc.outcome == 'success'
65+
66+
- name: Deploy to netlify with doc-TAG alias
67+
id: deploy-netlify
68+
uses: netlify/actions/cli@master
69+
with:
70+
args: deploy --dir=livedoc/livedoc --message ${NETLIFY_MESSAGE} --alias ${NETLIFY_ALIAS}
71+
env:
72+
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
73+
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
74+
NETLIFY_MESSAGE: doc-${{ steps.source-run-info.outputs.targetBranch }}
75+
NETLIFY_ALIAS: doc-${{ steps.source-run-info.outputs.targetBranch }}
76+
if: steps.download-doc.outcome == 'success'
77+
78+
- name: Deploy to netlify with doc-release alias
79+
uses: netlify/actions/cli@master
80+
with:
81+
args: deploy --dir=livedoc/livedoc --message doc-release --alias doc-release
82+
env:
83+
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
84+
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
85+
if: steps.download-doc.outcome == 'success'
86+
87+
- name: Report deployment url
88+
run: |
89+
echo "::notice::The live documentation has been deployed - ${{ steps.deploy-netlify.outputs.NETLIFY_URL }}"
90+
if: steps.download-doc.outcome == 'success'

.github/workflows/doc-publish.yml

Lines changed: 3 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Publish documentation
22

33
on:
44
workflow_run:
5-
workflows: ["Build documentation", "Build documentation (PDF)"]
5+
workflows: "Build documentation"
66
types:
77
- completed
88

@@ -12,15 +12,14 @@ permissions:
1212
pull-requests: write
1313

1414

15-
# This workflow runs after doc-build and doc-build-pdf workflows, taking the
16-
# artifact (doc/livedoc) and deploying it to a netlify site.
15+
# This workflow runs after doc-build workflow, taking the
16+
# artifact doc and deploying it to a netlify site.
1717
#
1818
# event (triggered doc-build) URL (of the doc deployed to NETLIFY_SITE)
1919
# --------------------------- ---------------------------------
2020
# on pull request https://doc-pr-12345--NETLIFY_SITE
2121
# on push branch develop https://doc-develop--NETLIFY_SITE
2222
# on push tag https://doc-10-4-beta2--NETLIFY_SITE
23-
# on push tag https://doc-release--NETLIFY_SITE
2423
#
2524
# where NETLIFY_SITE is presently sagemath.netlify.app for repo sagemath/sage.
2625
#
@@ -99,68 +98,3 @@ jobs:
9998
run: |
10099
echo "::notice::The documentation has been deployed - ${{ steps.deploy-netlify.outputs.NETLIFY_URL }}"
101100
if: steps.download-doc.outcome == 'success'
102-
103-
publish-live-doc:
104-
runs-on: ubuntu-latest
105-
if: github.event.workflow_run.conclusion == 'success'
106-
env:
107-
CAN_DEPLOY: ${{ secrets.NETLIFY_AUTH_TOKEN != '' && secrets.NETLIFY_SITE_ID != '' }}
108-
steps:
109-
- name: Get information about workflow origin
110-
uses: potiuk/get-workflow-origin@v1_5
111-
id: source-run-info
112-
with:
113-
token: ${{ secrets.GITHUB_TOKEN }}
114-
sourceRunId: ${{ github.event.workflow_run.id }}
115-
if: env.CAN_DEPLOY == 'true'
116-
117-
- name: Download live doc
118-
id: download-doc
119-
uses: actions/download-artifact@v4
120-
with:
121-
name: livedoc
122-
github-token: ${{ secrets.GITHUB_TOKEN }}
123-
repository: ${{ github.repository }}
124-
run-id: ${{ github.event.workflow_run.id }}
125-
# if the doc was built for tag push (targetBranch contains the tag)
126-
if: steps.source-run-info.outputs.sourceEvent == 'push' && steps.source-run-info.outputs.targetBranch != 'develop'
127-
128-
- name: Extract live doc
129-
run: unzip livedoc.zip -d livedoc
130-
if: steps.download-doc.outcome == 'success'
131-
132-
- name: Create _headers file for permissive CORS
133-
run: |
134-
cat <<EOF > livedoc/livedoc/_headers
135-
/*
136-
Access-Control-Allow-Origin: *
137-
Access-Control-Allow-Methods: GET
138-
Access-Control-Allow-Headers: Content-Type
139-
EOF
140-
if: steps.download-doc.outcome == 'success'
141-
142-
- name: Deploy to netlify with doc-TAG alias
143-
id: deploy-netlify
144-
uses: netlify/actions/cli@master
145-
with:
146-
args: deploy --dir=livedoc/livedoc --message ${NETLIFY_MESSAGE} --alias ${NETLIFY_ALIAS}
147-
env:
148-
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
149-
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
150-
NETLIFY_MESSAGE: doc-${{ steps.source-run-info.outputs.targetBranch }}
151-
NETLIFY_ALIAS: doc-${{ steps.source-run-info.outputs.targetBranch }}
152-
if: steps.download-doc.outcome == 'success'
153-
154-
- name: Deploy to netlify with doc-release alias
155-
uses: netlify/actions/cli@master
156-
with:
157-
args: deploy --dir=livedoc/livedoc --message doc-release --alias doc-release
158-
env:
159-
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
160-
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
161-
if: steps.download-doc.outcome == 'success'
162-
163-
- name: Report deployment url
164-
run: |
165-
echo "::notice::The live documentation has been deployed - ${{ steps.deploy-netlify.outputs.NETLIFY_URL }}"
166-
if: steps.download-doc.outcome == 'success'

0 commit comments

Comments
 (0)