This repository is currently being migrated. It's locked while the migration is in progress.
-
Notifications
You must be signed in to change notification settings - Fork 87
76 lines (74 loc) · 2.7 KB
/
deploy.yml
File metadata and controls
76 lines (74 loc) · 2.7 KB
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
name: Deploy site
on:
push:
branches:
- main
workflow_dispatch:
inputs:
reason:
description: 'Reason for manual deployment'
required: false
default: 'Manual deployment triggered'
# Prevent concurrent deploys from racing to write to S3.
# If a newer push arrives while a deploy is in progress, cancel the older one.
# The latest commit always has the most up-to-date content.
concurrency:
group: deploy-${{ github.ref }}
cancel-in-progress: true
jobs:
deploy:
strategy:
matrix:
environment: [{ bucket: staging-design.va.gov, config: staging.yml }, { bucket: design.va.gov, config: prod.yml }]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Use Node.js 20.x
uses: actions/setup-node@v3
with:
node-version: 20.x
cache: 'yarn'
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- run: yarn install
- run: yarn run build
- run: bundle exec jekyll build --config _config.yml,jekyll-configs/${{ matrix.environment.config }}
- name: Make BUILD.txt file
# The -e flag enables the interpretation of the \n newline character
run: |
echo -e "REF=${{ github.sha }}\n\
BUILD_ID=${{ github.run_id }}\n\
BUILDTIME=$(date)" > _site/BUILD.txt
# We are taking these extra steps due to some differences between Jekyll and AWS S3.
# To access a .html file served from S3, the URL needs to have the .html extension.
# We're removing the extension to make the URLs prettier.
# More context:
# https://simpleit.rocks/ruby/jekyll/tutorials/having-pretty-urls-in-a-jekyll-website-hosted-in-amazon-s3/
- name: Remove .html extension on non-index files
run: |
find _site/ -type f ! -iname 'index.html' -iname '*.html' \
-print0 | while read -d $'\0' f; do mv "$f" "${f%.html}"; done
- uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: "us-gov-west-1"
- name: Sync extensionless html files with correct type
run: |
aws s3 sync _site s3://${{ matrix.environment.bucket }} \
--acl public-read \
--delete \
--exclude "storybook/*" \
--exclude "*.*" \
--content-type "text/html"
- name: Sync remaining files
run: |
aws s3 sync _site s3://${{ matrix.environment.bucket }} \
--acl public-read \
--delete \
--exclude "*" \
--include "*.*" \
--exclude "storybook/*"