-
Notifications
You must be signed in to change notification settings - Fork 291
106 lines (84 loc) · 3.28 KB
/
deploy-gh-pages.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
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and site, and run the deploy script.
# The deploy script will publish the build to gh-pages.
# This workflow will be run whenever a new release is published.
# NOTE (pradeep): I'm having this workflow bail out if the release doesn't target v2.0.x
# This is because we don't have a way (yet) to support multiple FDT versions/docs be deployed at the same time,
# and hence we choose to deploy only the most stable release.
# Guide: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Deploy to gh-pages
on:
release:
types: [published]
# Allow only one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: true
jobs:
check-release:
name: Check release version
runs-on: ubuntu-latest
# map step output to job output
outputs:
is_stable: ${{ steps.check-release-stable.outputs.is_stable }}
steps:
- name: Check if release is stable
id: check-release-stable
env:
# Store the tag name of the release in `RELEASE_TAG` (eg: v1.0.10)
RELEASE_TAG: ${{ github.event.release.tag_name }}
# Check if the release tag name is a stable candidate for deployment
# NOTE (pradeep): Only allow 2.0.x versions to be deployed right now
run: |
echo "RELEASE_TAG is: " $RELEASE_TAG
if [[ $RELEASE_TAG =~ ^v2\.0\.[0-9]+$ ]];
then
echo "This is a stable release!"
echo "::set-output name=is_stable::true"
else
echo "This is not a stable release!"
echo "::set-output name=is_stable::false"
fi
build:
name: Build and upload artifacts
needs: check-release
runs-on: ubuntu-latest
# skip deploying to gh-pages if release is not "stable"
if: ${{ needs.check-release.outputs.is_stable == 'true' }}
steps:
# checkout our repo for the current commit
- name: Check out repo
uses: actions/checkout@v3
# setup node version 16 which is not old but still stable
- name: Use Node.js 16
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'yarn'
- name: Install dependencies
run: yarn install --frozen-lockfile # do a clean install of all of our dependencies
# build our static site contents
- name: Build static site!
run: yarn run site-build
# upload the static site contents as an artifact.
# the artifact is non-optional, and is consumed in the next job.
- name: Upload static site artifacts
uses: actions/[email protected]
with:
path: "__site__/"
deploy:
name: Deploy site
needs: build
runs-on: ubuntu-latest
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate soure
# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
# publish our site to gh-pages
- name: Deploy GitHub Pages
id: deployment
uses: actions/[email protected]