-
Notifications
You must be signed in to change notification settings - Fork 0
56 lines (45 loc) · 1.43 KB
/
github-actions-deploy.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
name: 'Website'
on:
push:
branches:
- main
pull_request:
jobs:
deploy:
name: 'deploy'
runs-on: ubuntu-20.04
defaults:
run:
shell: bash
permissions:
contents: read
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Ruby and install dependencies
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.3.6
bundler-cache: true
- name: Build
run: bundle exec jekyll build
- name: Authenticate with AWS
if: github.ref == 'refs/heads/main'
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::262312054792:role/jsherz-com-github-actions
aws-region: eu-west-1
- name: Sync files to S3
if: github.ref == 'refs/heads/main'
run: |
aws s3 sync \
--metadata-directive REPLACE \
--cache-control "max-age=86400" \
_site/ s3://jsj-prod-jsherz-com-website/
- name: Clear cache
if: github.ref == 'refs/heads/main'
run: |
DISTRIBUTION_ID=$(aws cloudfront list-distributions | jq --raw-output '.DistributionList.Items | map(select((.Aliases.Quantity >= 1) and (.Aliases.Items | contains(["jsherz.com"])))) | .[0].Id')
export PAGER=""
aws cloudfront create-invalidation --distribution-id ${DISTRIBUTION_ID} --path '/*'