-
Notifications
You must be signed in to change notification settings - Fork 19
156 lines (137 loc) · 5.19 KB
/
nightly.yml
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
# THIS FILE IS PART OF THE CYLC WORKFLOW ENGINE.
# Copyright (C) NIWA & British Crown (Met Office) & Contributors.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Deploy a new version of the documentation or rebuild an existing one.
# Note: This action deletes its previous commits so the nightly build history
# is not preserved and does not require housekeeping.
name: nightly
on:
workflow_dispatch:
schedule:
- cron: '35 0 * * *'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
jobs:
set-meta-releases:
# read the meta-release versions from the branches.json file
runs-on: ubuntu-latest
timeout-minutes: 2
outputs:
meta-releases: ${{ steps.set-meta-releases.outputs.meta-releases }}
steps:
- name: install libs
id: set-meta-releases
uses: cylc/release-actions/set-meta-releases@v1
deploy:
needs: set-meta-releases
runs-on: ubuntu-latest
timeout-minutes: 10
defaults:
run:
# use login shell for conda activation
shell: bash -leo pipefail {0}
strategy:
# run one job per meta-release
matrix:
meta_release: ${{ fromJson(needs.set-meta-releases.outputs.meta-releases) }}
# don't stop if one job fails
fail-fast: false
# only run one job at a time
max-parallel: 1
steps:
- name: configure python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: checkout cylc-doc
uses: actions/checkout@v3
with:
path: docs
- name: install dependencies
uses: ./docs/.github/actions/install-dependencies
- name: install cylc-doc
run: pip install "${{ github.workspace }}/docs[all]"
- name: install libs to document
uses: cylc/release-actions/install-cylc-components@v1
with:
meta_release: ${{ matrix.meta_release }}
cylc_flow: true
cylc_flow_opts: 'main_loop-log_data_store,main_loop-log_db,main_loop-log_main_loop,main_loop-log_memory'
cylc_uiserver: true
cylc_uiserver_opts: ''
cylc_rose: true
cylc_rose_opts: ''
metomi_rose: true
metomi_rose_opts: ''
- name: checkout gh-pages branch
uses: actions/checkout@v3
with:
ref: gh-pages
path: gh-pages
fetch-depth: 0 # all history (unfortunately all branches too)
- name: install gh-pages
run: |
DOCS="${{ github.workspace }}/docs" \
PAGE="${{ github.workspace }}/gh-pages" \
cd "$DOCS"
rm -r doc
ln -s "$PAGE" doc
- name: configure git
uses: cylc/release-actions/configure-git@v1
- name: remove previous nightly build
id: remove-prev-build
working-directory: gh-pages
continue-on-error: true
run: |
echo "::group::History before rebase: (you can still fetch these commits for recovery)"
git log --oneline --graph --no-abbrev-commit gh-pages
echo "::endgroup::"
echo "[command]git rebase -i --root"
# drop all "-nightly build-" commits which didn't come from this workflow run
EDITOR="sed -i '/-nightly build ${GITHUB_RUN_ID}-/! s/pick \(.* -nightly build\)/drop \1/'" \
git rebase -i --root
# if versions have been added/removed since the last build, we will
# get conflicts on the versions.json file, so need to rebuild it
- name: fix rebase conflict
if: steps.remove-prev-build.outcome == 'failure'
working-directory: gh-pages
run: |
git diff --diff-filter=U
echo "[command]../docs/bin/version . write > versions.json"
../docs/bin/version . write > versions.json
echo "[command]git add versions.json"
git add versions.json
echo "[command]git rebase --continue"
EDITOR=: git rebase --continue
- name: build docs
run: |
version="nightly:${{ matrix.meta_release}}.$(isodatetime --utc -f %Y-%m-%d)"
builddir="nightly_${{ matrix.meta_release }}"
make -C docs \
html \
slides \
linkcheck \
SPHINXOPTS="-Wn --keep-going -A sidebar_version_name=${version}" \
STABLE=false \
LATEST=false \
BUILDDIR="doc/$builddir" \
FORCE_COLOR=true
git -C gh-pages add "$builddir" 'versions.json'
- name: push changes
working-directory: gh-pages
run: |
git status
git commit -m "-nightly build ${GITHUB_RUN_ID}-"
git push --force-with-lease origin gh-pages