-
Notifications
You must be signed in to change notification settings - Fork 17
111 lines (96 loc) · 3.53 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
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
name: Build and deploy docs
on:
push:
branches: [main]
pull_request:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10"]
fail-fast: false
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Upgrade pip
run: python -m pip install --upgrade pip
# =====================================================
# Install dependencies
# =====================================================
- name: Check out submodules
run: |
make submodules
- uses: quarto-dev/quarto-actions/setup@v2
with:
version: 1.4.557
- name: Install R
uses: r-lib/actions/setup-r@v2
- uses: r-lib/actions/setup-r-dependencies@v2
with:
install-quarto: false
packages: |
any::knitr
any::rmarkdown
any::reticulate
- name: Install build dependencies
run: |
make deps
# =====================================================
# Build
# =====================================================
- name: Build site
run: |
make all
# =====================================================
# Deploy docs to Netlify
# =====================================================
- name: Configure pull release name
if: ${{github.event_name == 'pull_request'}}
env:
PR_NUMBER: ${{ github.event.number }}
run: |
echo "RELEASE_NAME=pr-${PR_NUMBER}" >> $GITHUB_ENV
- 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
- name: Create Github "view deployment" button in PR
if: ${{github.event_name == 'pull_request'}}
uses: bobheadxi/deployments@v1
id: deployment
with:
step: start
token: ${{ secrets.GITHUB_TOKEN }}
env: ${{ env.RELEASE_NAME }}
ref: ${{ github.head_ref }}
logs: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
- name: Deploy to Netlify
env:
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
REF_NAME: ${{ github.ref_name }}
ALIAS: ${{ steps.deployment.outputs.env }}
run: |
npm install -g [email protected]
# push main branch to production, others to preview --
if [ "${REF_NAME}" == "main" ]; then
netlify deploy --dir=_build/ --prod
else
netlify deploy --dir=_build/ --alias="${ALIAS}"
fi
- name: Update Github "view deployment" button in PR
uses: bobheadxi/deployments@v1
if: ${{ steps.deployment.conclusion != 'failure' && github.event_name == 'pull_request'}}
with:
step: finish
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
env: ${{ steps.deployment.outputs.env }}
env_url: "https://${{ steps.deployment.outputs.env }}--pyshiny.netlify.app"
logs: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"