-
Notifications
You must be signed in to change notification settings - Fork 2
40 lines (32 loc) · 1.52 KB
/
deploy_s3.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
# Build site and sync with S3
# To test this action with act (https://github.com/nektos/act) run:
# act --secret ACADEMY_S3_ACCESS_KEY_ID=xxx --secret ACADEMY_S3_SECRET_ACCESS_KEY=xxx --secret ACADEMY_S3_REGION=xxx --secret ACADEMY_S3_BUCKET=xxx
# Note however that the aws binary is not available in self-hosted runners.
name: Deploy to S3
on:
push:
branches: [ master, main ]
jobs:
deploy_to_s3:
name: Build and sync with S3
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Install Python requirements
run: pip install -r requirements.txt
- name: Install system requirements
run: sudo apt update && sudo apt install -y pandoc
- name: Build site
run: make build
# https://github.com/aws-actions/configure-aws-credentials?tab=readme-ov-file#assumerole-with-static-iam-credentials-in-repository-secrets
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.ACADEMY_S3_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.ACADEMY_S3_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.ACADEMY_S3_REGION }}
- name: Sync build assets with S3
run: aws s3 sync --delete _build/academy/ s3://${{ secrets.ACADEMY_S3_BUCKET }}/academy/
- name: Clear cloudfront cache
run: aws cloudfront create-invalidation --distribution-id ${{ secrets.ACADEMY_CLOUDFRONT_DISTRIBUTION }} --paths "/academy/*"