This repository has been archived by the owner on Jul 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
71 lines (66 loc) · 2.05 KB
/
deploy_docs.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
name: Deploy Docs
on:
workflow_run:
workflows:
- Build Docs
types:
- completed
jobs:
deploy:
name: Deploy Docs
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Get GitHub Pages Data
uses: actions/github-script@v3
id: pages-data
with:
script: |
const result = await github.request('GET /repos/{owner}/{repo}/pages', {
owner: context.repo.owner,
repo: context.repo.repo
})
return result.data
- name: Lock workflow
uses: softprops/turnstyle@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
poll-interval-seconds: 10
- name: Checkout docs branch
uses: actions/checkout@v2
with:
ref: refs/heads/${{ fromJSON(steps.pages-data.outputs.result).source.branch }}
- name: Download artifact
uses: dawidd6/action-download-artifact@v2
with:
workflow: ${{ github.event.workflow_run.name }}
run_id: ${{ github.event.workflow_run.id }}
name: doc
- name: Update versions
run: |
pip install packaging
python update_versions.py
- name: Get SHA & ref
run: |
echo "GITHUB_SHA_SHORT=$(echo ${{ github.event.workflow_run.head_sha }} | cut -c 1-7)" >> $GITHUB_ENV
echo "REF=$(cat ref.txt)" >> $GITHUB_ENV
rm -f ref.txt
- name: Deploy docs
run: |
git config user.name "GitHub Action"
git config user.email "[email protected]"
git add -A
if ! git diff-index --quiet HEAD --; then
echo "Deploying changes"
git status
git commit -m "Deploy docs from ${{ github.event.workflow_run.head_branch }} @ ${{ env.GITHUB_SHA_SHORT }}"
git push -f
else
echo "No changes to deploy"
exit 0
fi
env:
GITHUB_TOKEN: ${{ secrets.PAGE_TOKEN }}