-
Notifications
You must be signed in to change notification settings - Fork 52
80 lines (76 loc) · 2.58 KB
/
doc-site.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
## The is a combination of sites where
## Zero serves on the root of the domain /
## and module serves on /docs/modules/<path>/
# from the same S3 bucket
name: "Build Documentation Site"
on:
push:
branches:
- main
paths:
- doc-site/**
env:
region: us-west-2
s3_sync_path_to_exclude: docs/modules/*
s3_sync_path: ""
BUILD_DOMAIN: ${{ secrets.ZERO_DOC_SITE_DOMAIN_NAME }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup node.js
uses: actions/setup-node@v3
with:
node-version: 16
# - name: Documentaiton site folder
# run: cd doc-site
- name: Install Dependencies
working-directory: doc-site
run: npm install
- name: Build website
working-directory: doc-site
run: |
npm run build
pwd
ls -la
- name: Upload build artifact to Github
uses: actions/upload-artifact@v2
with:
name: build-artifact
path: doc-site/build
deploy:
name: Deploy
runs-on: ubuntu-latest
needs: build
# These permissions are needed to interact with GitHub's OIDC Token endpoint.
permissions:
id-token: write
contents: read
steps:
# Once github action supports nested composite actions (anything `uses` is a composite action)
# Therefore we cannot reuse the code as a separate composite action until it supports it,
# current the deploy logic is in this file twice because of it
## https://github.com/actions/runner/issues/862
- uses: actions/checkout@v2
- name: Configure AWS credentials for S3 sync
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.ZERO_DOC_SITE_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.ZERO_DOC_SITE_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.region }}
- name: Download build artifact from Github
uses: actions/download-artifact@v1
with:
name: build-artifact
path: build/
- name: Sync with S3
shell: bash
run: |
cd build
aws s3 sync . "s3://${{ secrets.ZERO_DOC_SITE_BUCKET_NAME }}${{ env.s3_sync_path }}" --exclude "${{ env.s3_sync_path_to_exclude }}" --delete
- name: Invalidate Cloudfront
shell: bash
run: |
export DIST_ID=$(aws cloudfront list-distributions --query "DistributionList.Items[?Aliases.Items[?@=='${{ secrets.ZERO_DOC_SITE_BUCKET_NAME }}']].Id | [0]" | tr -d '"')
aws cloudfront create-invalidation --distribution-id ${DIST_ID} --paths "/*"