-
Notifications
You must be signed in to change notification settings - Fork 4
101 lines (97 loc) · 3.93 KB
/
ci.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
101
name: CI + Deployment
on:
push:
branches: [ 'staging', 'main' ] # TODO: Change later
jobs:
ci:
runs-on: ubuntu-latest
env:
NOKOGIRI_USE_SYSTEM_LIBRARIES: true
steps:
- uses: actions/checkout@v2
- name: Install libxslt for nokogiri gem (required for version < 1.11)
run: sudo apt-get install -y libxml2-dev libxslt-dev
- name: Add --no-document option to .gemrc file to speed up bundle install
run: "echo 'gem: --no-document' > ~/.gemrc"
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7.5
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Build jekyll site
run: bundle exec jekyll build
- name: Run tests
run: bundle exec rake test
# This step will only run for certain branches:
- name: Optionally zip up the built site (if deploying)
if: contains(fromJson('["refs/heads/staging", "refs/heads/main"]'), github.ref)
run: zip -q -r ./_site.zip ./_site
# This step will only run for certain branches:
# Note: The upload-artifact step is slow for lots of files, but fast for a single zip file.
- name: Optionally store site build for subsequent deployment step (if deploying)
if: contains(fromJson('["refs/heads/staging", "refs/heads/main"]'), github.ref)
uses: actions/upload-artifact@v3
with:
name: built-site
path: _site.zip
deploy:
# This job will only run on certain branches
if: contains(fromJson('["refs/heads/staging", "refs/heads/main"]'), github.ref)
needs: ci
runs-on: ubuntu-latest
env:
AWS_ACCESS_KEY_ID: ${{ secrets.DLST_SERV_DEPLOY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.DLST_SERV_DEPLOY_KEY }}
AWS_REGION: 'us-west-2'
steps:
- name: Download built-site artifact from previous CI job
uses: actions/download-artifact@v3
with:
name: built-site
- name: Unzip the downloaded artifact
run: unzip -q ./_site.zip
- name: ls the unzipped artifact
run: ls -la ./_site
- name: If staging branch, deploy to staging
if: github.ref == 'refs/heads/staging'
# GitHub Actions includes the AWS CLI by default, so we can just use it directly
run: >
aws s3 sync
./_site
${{ secrets.STAGING_BUCKET_NAME }}
--follow-symlinks --delete
- name: If main branch, deploy to prod
if: github.ref == 'refs/heads/main'
run: >
aws s3 sync
./_site
${{ secrets.REPO_BUCKET_NAME }}
--follow-symlinks --delete
# deploy-to-s3:
# if: github.ref == 'refs/heads/master' # this job should only run on the master branch
# needs: ci # This job should only run after the ci job completes successfully
# runs-on: ubuntu-latest
# env:
# NOKOGIRI_USE_SYSTEM_LIBRARIES: true
# AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
# AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# steps:
# - uses: actions/checkout@v2
# - name: Install libxslt for nokogiri gem (required for version < 1.11)
# run: sudo apt-get install -y libxml2-dev libxslt-dev
# - name: Add --no-document option to .gemrc file to speed up bundle install
# run: "echo 'gem: --no-document' > ~/.gemrc"
# - name: Set up Ruby
# uses: ruby/setup-ruby@v1
# with:
# # We build and deploy with a specific version of ruby
# ruby-version: ${{ env.RUBY_VERSION_FOR_DEPLOYMENT }}
# bundler-cache: true # runs 'bundle install' and caches installed gems automatically
# - name: Build jekyll site
# run: bundle exec jekyll build
# - name: Deployment
# uses: reggionick/s3-deploy@v3
# with:
# folder: _site
# bucket: cul-s3-dlst-travis-studio-staging
# bucket-region: us-west-2