Skip to content

Commit da87c65

Browse files
committed
add netlify docs preview gha
1 parent 157544a commit da87c65

1 file changed

Lines changed: 53 additions & 0 deletions

File tree

.github/workflows/docs.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,59 @@ jobs:
3131
with:
3232
name: docs-html
3333
path: docs/_site
34+
# push to netlify -------------------------------------------------------
35+
36+
# set release name ----
37+
38+
- name: Configure pull release name
39+
if: ${{github.event_name == 'pull_request'}}
40+
run: |
41+
echo "RELEASE_NAME=pr-${PR_NUMBER}" >> $GITHUB_ENV
42+
env:
43+
PR_NUMBER: ${{ github.event.number }}
44+
- name: Configure branch release name
45+
if: ${{github.event_name != 'pull_request'}}
46+
run: |
47+
# use branch name, but replace slashes. E.g. feat/a -> feat-a
48+
echo "RELEASE_NAME=${GITHUB_REF_NAME/\//-}" >> $GITHUB_ENV
49+
# deploy ----
50+
51+
- name: Create Github Deployment
52+
uses: bobheadxi/deployments@v0.4.3
53+
id: deployment
54+
with:
55+
step: start
56+
token: ${{ secrets.GITHUB_TOKEN }}
57+
env: ${{ env.RELEASE_NAME }}
58+
ref: ${{ github.head_ref }}
59+
transient: true
60+
logs: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'
61+
62+
- name: Netlify docs preview
63+
run: |
64+
npm install -g netlify-cli
65+
# push main branch to production, others to preview --
66+
if [ "${ALIAS}" == "main" ]; then
67+
netlify deploy --dir=_site --alias="main"
68+
else
69+
netlify deploy --dir=_site --alias="${ALIAS}"
70+
fi
71+
env:
72+
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
73+
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
74+
ALIAS: ${{ steps.deployment.outputs.env }}
75+
76+
- name: Update Github Deployment
77+
uses: bobheadxi/deployments@v0.4.3
78+
if: ${{ always() }}
79+
with:
80+
step: finish
81+
token: ${{ secrets.GITHUB_TOKEN }}
82+
status: ${{ job.status }}
83+
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
84+
env_url: 'https://${{ steps.deployment.outputs.env }}--taupe-sprinkles-23996f.netlify.app'
85+
logs: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'
86+
3487
- name: publish dev docs
3588
if: github.ref_name == 'main' && github.ref_type == 'branch'
3689
uses: peaceiris/actions-gh-pages@v3

0 commit comments

Comments
 (0)