-
Notifications
You must be signed in to change notification settings - Fork 176
96 lines (83 loc) · 2.62 KB
/
docs_deploy.yaml
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
# This is a special and separate job because of sphinx multiversion
# checks out random tips of other branches and the code isn't build just from
# what triggered the event. For any branch that changes we need to always
# build and deploy from master :(
# Triggering a job from multiple branches in parallel is racy, but it's what we have :(
# The scheduled job will eventually fix it.
name: Deploy Docs
on:
push:
branches:
- 'master'
- 'v[0-9]+.[0-9]+'
paths:
- 'docs/**'
- '.github/**'
schedule:
- cron: '0 23 * * *' # daily at 11pm
workflow_dispatch:
env:
retention_days: 90
jobs:
build-and-test:
name: Build
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: 'master'
persist-credentials: false
fetch-depth: 0
- name: Setup dependencies
uses: ./.github/actions/docs/setup
- name: Build
uses: ./.github/actions/docs/build
with:
build_target: "multiversion"
deploy:
name: Deploy
runs-on: ubuntu-22.04
needs:
- build-and-test
steps:
- uses: actions/download-artifact@v3
with:
name: docs.tar.xz
path: ~/
- name: Deploy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run : |
set -euExo pipefail
shopt -s inherit_errexit
cd "$( mktemp -d )"
tar -xJf ~/docs.tar.xz ./dirhtml --strip-components=2
# Sanity check
[[ -f index.html ]]
git init
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add .
git commit -m "Publish docs"
git push --force "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" master:gh-pages
failure-notifications:
name: Failure notifications
runs-on: ubuntu-22.04
needs:
- build-and-test
- deploy
if: ${{ failure() }}
steps:
- name: Report failures to Slack
if: ${{ always() }}
working-directory: .
run: |
# We have to avoid printing the secret to logs.
set +x
curl -X POST -H 'Content-type: application/json' --data @<( cat <<-EOF
{
"text": ":warning: CI workflow \"${{ github.workflow }}\" triggered on \"${{ github.event_name }}\" event from ${{ github.ref }} (${{ github.sha }}) failed!\n:fire_extinguisher: See https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} for details.:fire:\ncc: <@U01L8R3RYFN> <@UN90LVATC>"
}
EOF
) '${{ secrets.SLACK_WEBHOOK_URL }}'