-
Notifications
You must be signed in to change notification settings - Fork 0
67 lines (57 loc) · 2.19 KB
/
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
name: CI
on: [push]
jobs:
test-build:
name: Test Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Babel and Jest Modules
run: npm install
- name: Build Jekyll Files
run: |
docker run \
-v ${{ github.workspace }}:/srv/jekyll -v ${{ github.workspace }}/_site:/srv/jekyll/_site \
jekyll/builder:latest /bin/bash -c "chmod a+w /srv/jekyll/Gemfile.lock && chmod 777 /srv/jekyll/src && jekyll build --config _config.yml,_config.test.yml --future --trace"
- name: Run Jest Tests
run: npm run test:ci
production-build:
name: Production Build
runs-on: ubuntu-latest
needs: [test-build]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v3
- name: Build Jekyll Files
run: |
docker run \
-v ${{ github.workspace }}:/srv/jekyll -v ${{ github.workspace }}/_site:/srv/jekyll/_site \
jekyll/builder:latest /bin/bash -c "chmod a+w /srv/jekyll/Gemfile.lock && chmod 777 /srv/jekyll/src && jekyll build --config _config.yml --future --trace"
- name: Archive artifacts
uses: actions/upload-artifact@v3
with:
name: built-jekyll-files
path: _site
retention-days: 1
deploy:
name: Deployment
runs-on: ubuntu-latest
needs: [production-build]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- name: Download built site artifact
uses: actions/download-artifact@v3
with:
name: built-jekyll-files
path: _site
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v3
with:
mask-aws-account-id: true
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-west-2
- name: Deploy to S3 bucket
run: aws s3 sync ./_site/ ${{ secrets.S3_BUCKET }} --delete
- name: Invalidate CloudFront Objects
run: aws cloudfront create-invalidation --distribution-id ${{ secrets.CLOUDFRONT_DIST_ID }} --path "/*"