-
Notifications
You must be signed in to change notification settings - Fork 8
73 lines (70 loc) · 2.42 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
name: "Build Documentation Site"
on:
push:
branches:
- main
- doc-site
paths:
- doc-site/**
env:
region: us-west-2
s3_sync_path: /docs/modules/aws-eks-stack
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@v1
with:
node-version: 14.x
- name: Install Dependencies
working-directory: doc-site
run: npm install
# This allows us to simply re-run a previous CI
# and get a newer set of common-elements
- name: Update doc-site common elements
working-directory: doc-site
run: npm up @commitdev/zero-doc-site-common-elements
- name: Build website
working-directory: doc-site
run: |
npm run build
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
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 }}" --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 "${{ env.s3_sync_path }}*"