-
Notifications
You must be signed in to change notification settings - Fork 73
85 lines (79 loc) · 2.8 KB
/
ci-docs.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
on:
push:
branches:
- main
- "docs-preview-**"
pull_request:
branches:
- main
name: CI Docs
jobs:
build-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install ".[all]"
- uses: quarto-dev/quarto-actions/setup@v2
- name: Build docs
run: |
make docs-build
# push to netlify -------------------------------------------------------
# set release name ----
- name: Configure pull release name
if: ${{github.event_name == 'pull_request'}}
run: |
echo "RELEASE_NAME=pr-${PR_NUMBER}" >> $GITHUB_ENV
env:
PR_NUMBER: ${{ github.event.number }}
- name: Configure branch release name
if: ${{github.event_name != 'pull_request'}}
run: |
# use branch name, but replace slashes. E.g. feat/a -> feat-a
echo "RELEASE_NAME=${GITHUB_REF_NAME/\//-}" >> $GITHUB_ENV
# deploy ----
- name: Create Github Deployment
uses: bobheadxi/deployments@v1
id: deployment
if: ${{ !github.event.pull_request.head.repo.fork }}
with:
step: start
token: ${{ secrets.GITHUB_TOKEN }}
env: ${{ env.RELEASE_NAME }}
ref: ${{ github.head_ref }}
transient: true
logs: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
- name: Netlify docs preview
if: ${{ !github.event.pull_request.head.repo.fork }}
run: |
npm install -g netlify-cli
# push main branch to production, others to preview --
netlify link --name="gt-python"
if [ "${ALIAS}" == "main" ]; then
netlify deploy --dir=docs/_site --alias="main"
else
netlify deploy --dir=docs/_site --alias="${ALIAS}"
fi
env:
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
ALIAS: ${{ steps.deployment.outputs.env }}
- name: Update Github Deployment
uses: bobheadxi/deployments@v1
if: ${{ !github.event.pull_request.head.repo.fork && always() }}
with:
step: finish
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
env: ${{ steps.deployment.outputs.env }}
env_url: "https://${{ steps.deployment.outputs.env }}--gt-python.netlify.app"
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
- uses: peaceiris/actions-gh-pages@v3
if: github.ref == 'refs/heads/main'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: docs/_site