forked from Qiskit/qiskit
-
Notifications
You must be signed in to change notification settings - Fork 0
221 lines (193 loc) · 7.33 KB
/
docs_deploy.yml
File metadata and controls
221 lines (193 loc) · 7.33 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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
name: Documentation
on:
push:
branches:
- main
- 'stable/*'
tags:
- '*'
workflow_dispatch:
inputs:
deploy_prefix:
description: "Deployment prefix (leave blank for the root): https://qiskit.org/documentation/<prefix>."
required: false
type: string
do_deployment:
description: "Push to qiskit.org?"
required: false
type: boolean
do_translatables:
description: "Push translatable strings?"
required: false
type: boolean
jobs:
build:
if: github.repository_owner == "Qiskit"
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
# We need to fetch the whole history so 'reno' can do its job.
fetch-depth: 0
- uses: actions/setup-python@v4
name: Install Python
with:
# Sync with 'documentationPythonVersion' in 'azure-pipelines.yml'.
python-version: '3.9'
- name: Install dependencies
run: tools/install_ubuntu_docs_dependencies.sh
# Sync with '.azure/tutorials-linux.yml'.
- name: Download current tutorials
run: tools/prepare_tutorials.bash algorithms circuits circuits_advanced operators
shell: bash
# This is just to have tox create the environment, so we can use it to execute the tutorials.
# We want to re-use it later for the build, hence 'tox run --notest' instead of 'tox devenv'.
- name: Prepare Python environment
run: tox run -e docs --notest
# The reason to use the custom script rather than letting 'nbsphinx' do its thing normally
# within the Sphinx build is so that the execution process is the same as in the test CI.
- name: Execute tutorials in place
run: .tox/docs/bin/python tools/execute_tutorials.py docs/tutorials
env:
QISKIT_CELL_TIMEOUT: "300"
- name: Build documentation
# We can skip re-installing the package, since we just did it a couple of steps ago.
run: tox run -e docs --skip-pkg-install
env:
QISKIT_ENABLE_ANALYTICS: "true"
# We've already built them.
QISKIT_DOCS_BUILD_TUTORIALS: "never"
- name: Build translatable strings
run: tox -e gettext
env:
# We've already built them.
QISKIT_DOCS_BUILD_TUTORIALS: "never"
- name: Store built documentation artifact
uses: actions/upload-artifact@v3
with:
name: qiskit-docs
path: |
./docs/_build/html/*
!**/.doctrees
!**/.buildinfo
if-no-files-found: error
- name: Store translatable strings artifact
uses: actions/upload-artifact@v3
with:
name: qiskit-translatables
path: ./docs/locale/en/*
if-no-files-found: error
deploy:
if: github.event_name != 'workflow_dispatch' || inputs.do_deployment
name: Deploy to qiskit.org
needs: [build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
path: qiskit
- uses: actions/download-artifact@v3
with:
name: qiskit-docs
path: deploy
- id: choose
name: Choose deployment location
run: |
set -e
case ${{ github.event_name }} in
push)
case ${{ github.ref_name }} in
main)
echo "deploy_prefix=dev" >> "$GITHUB_OUTPUT"
;;
# This currently deploys to the documentation root on a push to _any_ stable branch;
# when we're supporting more than one version at once, it will need revisiting.
stable/*)
echo "deploy_prefix=" >> "$GITHUB_OUTPUT"
;;
*)
echo "Push to unhandled branch ${{ github.ref_name }}" >&2
exit 1
;;
esac
;;
tag)
tag=${{ github.ref_name }}
echo "Full tag: ${tag}"
IFS=. read -ra version <<< "$tag"
minor_version="${version[0]}.${version[1]}"
echo "Minor version: ${minor_version}"
echo "deploy_prefix=stable/${minor_version}" >> "$GITHUB_OUTPUT"
;;
workflow_dispatch)
echo "deploy_prefix=${{ inputs.deploy_prefix }}" >> "$GITHUB_OUTPUT"
;;
*)
echo "Unhandled GitHub event ${{ github.event_name }}" >&2
exit 1
;;
esac
- name: Install rclone
run: |
set -e
curl https://downloads.rclone.org/rclone-current-linux-amd64.deb -o rclone.deb
sudo apt-get install -y ./rclone.deb
- name: Deploy to qiskit.org
run: |
set -e
RCLONE_CONFIG=$(rclone config file | tail -1)
openssl aes-256-cbc -K "$RCLONE_KEY" -iv "$RCLONE_IV" -in qiskit/tools/rclone.conf.enc -out "$RCLONE_CONFIG" -d
rclone sync --progress --exclude-from qiskit/tools/docs_exclude.txt deploy "IBMCOS:qiskit-org-web-resources/documentation/${{ steps.choose.outputs.deploy_prefix }}"
env:
RCLONE_KEY: ${{ secrets.encrypted_rclone_key }}
RCLONE_IV: ${{ secrets.encrypted_rclone_iv }}
deploy_translatables:
if: (github.event_name == 'workflow_dispatch' && inputs.do_translatables) || (github.event_name == 'push' && startsWith(github.ref_name.startsWith, 'stable/'))
name: Push translatable strings
needs: [build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
path: 'qiskit'
- uses: actions/download-artifact@v3
with:
name: qiskit-translatables
path: 'deploy'
- name: Decrypt SSH secret key
id: ssh_key
run: |
set -e
ssh_key=$(openssl enc -aes-256-cbc -d -in qiskit/tools/github_poBranch_update_key.enc -K $SSH_UPDATE_KEY -iv $SSH_UPDATE_IV)
echo "::add-mask::${ssh_key}"
echo "ssh_key=${ssh_key}" >> "$GITHUB_OUTPUT"
- uses: actions/checkout@v3
with:
repository: 'qiskit-community/qiskit-translations'
path: 'qiskit-translations'
ssh-key: '${{ steps.ssh_key.outputs.ssh_key }}'
- name: Remove ignored documents
run: rm -r LC_MESSAGES/{apidocs,stubs}
working-directory: 'deploy'
- name: Push changes to translations repository
run: |
set -e
shopt -s failglob
# Bring the new `.po` target files into the repository.
git rm -r --ignore-unmatch docs/locale/en
mv "${{ github.workspace }}/deploy" docs/locale/en
# Update the ways to recreate the build.
cp "${{ github.workspace }}/qiskit/"{setup.py,requirements-*.txt,constraints.txt} .
git add .
cat > COMMIT_MSG << EOF
Automated documentation update to add .po files from ${{ github.repository }}
skip ci
Commit: ${{ github.sha }}
GitHub Actions run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
EOF
git config user.name "Qiskit Autodeploy"
git config user.email "qiskit@qiskit.org"
git commit -F COMMIT_MSG
git push origin
working-directory: 'qiskit-translations'