-
Notifications
You must be signed in to change notification settings - Fork 2
101 lines (91 loc) · 3.69 KB
/
eleventy_build_main.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
name: 11ty build Production Site
# site: https://headless.cannabis.ca.gov
# s3 bucket http://headless.cannabis.ca.gov.s3-website-us-west-1.amazonaws.com/
# editor: https://api.cannabis.ca.gov
on:
workflow_run:
workflows: ["Update static content [main]"]
types: ['completed']
branches:
- main
push:
branches:
- main
concurrency:
group: sync_deployments
cancel-in-progress: true
jobs:
build_deploy:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
cache: 'npm'
- name: Install packages
run: |
mkdir dist
npm ci --production
- name: Build 11ty
run: |
SITE_ENV=production DOMAIN=cannabis.ca.gov npm run build
- name: Write robots.txt
run: |
echo 'User-agent: *' > docs/robots.txt
echo 'Allow: /' >> docs/robots.txt
echo 'Sitemap: https://cannabis.ca.gov/sitemap.xml' >> docs/robots.txt
# deploy built files to separate branch that contains only built files that github pages uses to serve site
- name: Deploy to github pages branch
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs
publish_branch: deploy_production
# Set up AWS CLI
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-1
# Deploy to cannabis.ca.gov
# jbum added exclude
- name: Deploy to S3 (cannabis.ca.gov)
run: aws s3 sync --follow-symlinks --delete ./docs s3://cannabis.ca.gov --exclude 'wp-content/uploads/*'
# Reset the cache-control headers on static assets on production S3 bucket
- name: Reset cache-control on fonts
uses: prewk/s3-cp-action@v2
with:
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws_region: 'us-west-1' # optional: defaults to us-east-1
source: './docs/fonts'
dest: 's3://cannabis.ca.gov/fonts'
flags: --recursive --cache-control max-age=15552000
- name: Reset cache-control on assets
uses: prewk/s3-cp-action@v2
with:
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws_region: 'us-west-1' # optional: defaults to us-east-1
source: './docs/assets'
dest: 's3://cannabis.ca.gov/assets'
flags: --recursive --cache-control max-age=15552000
# - name: Reset cache-control on media
# uses: prewk/s3-cp-action@v2
# with:
# aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
# aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# aws_region: 'us-west-1' # optional: defaults to us-east-1
# source: './docs/wp-content/uploads/sites/2'
# dest: 's3://cannabis.ca.gov/wp-content/uploads/sites/2'
# flags: --recursive --cache-control max-age=15552000
- name: Deploy redirects
run: |
AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }} npm run deploy:redirects
- name: Invalidate Cloudfront (cannabis.ca.gov)
env:
AWS_RETRY_MODE: standard
AWS_MAX_ATTEMPTS: 6
run: aws cloudfront create-invalidation --distribution-id E2RLC9PDB1JLNI --paths "/*"