Skip to content

ci: clear cloudfront cache on deploy #5

ci: clear cloudfront cache on deploy

ci: clear cloudfront cache on deploy #5

Workflow file for this run

# 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/*"