-
Notifications
You must be signed in to change notification settings - Fork 9
77 lines (65 loc) · 2.48 KB
/
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
name: Build Docs
on:
push:
branches: [main, staging]
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
env:
BUCKET_NAME: ${{ github.ref == 'refs/heads/main' && 's3://www.fused.io/' || 's3://docs-staging.fused.io/' }}
CLOUDFRONT_ID: ${{ github.ref == 'refs/heads/main' && 'E2ZP0BRHQ20MYJ' || 'E33Z2H4C1WZOKH' }}
jobs:
publish-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# Auth with OIDC:
# https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/configuring-openid-connect-in-amazon-web-services
- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::926411091187:role/github_website_role
role-session-name: GithubFusedLabsFusedPyReleaseDocs
aws-region: us-west-2
- name: Use Node.js
id: setup-node
uses: actions/setup-node@v3
with:
node-version: 23.1.0
- name: Cache node modules
id: cache-npm
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }}
name: List the state of node modules
continue-on-error: true
run: npm list
- name: Install dependencies
run: npm install
- name: Build docs
env:
DEPLOYMENT_URL: 'https://docs.fused.io'
BASE_URL: '/'
IS_STAGING: 'false'
run: npm run build
#-------------------------------#
# Push the website #
#-------------------------------#
# After running the build, copy the contents to the S3 bucket to be served, and invalidate the CloudFront cache so it starts serving the new content:
- name: Publish website
shell: bash
run: |
aws s3 sync ./build $BUCKET_NAME --delete
- name: Invalidate CloudFront distribution
shell: bash
run: |
aws cloudfront create-invalidation --distribution-id $CLOUDFRONT_ID --paths '/*'