-
Notifications
You must be signed in to change notification settings - Fork 0
35 lines (32 loc) · 1.02 KB
/
deploy.yaml
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
---
name: Deploy to S3
concurrency: deploy-to-s3
on:
push:
branches: [main]
workflow_dispatch:
jobs:
deploy-site:
name: Deploy
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- name: Clone the repository
uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-east-1
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/${{ secrets.AWS_ROLE_NAME }}
role-session-name: Deployment${{ github.run_id }}-${{ github.run_attempt }}
role-duration-seconds: 900
- name: Copy to S3
run: |
STAGING_DIR="$(mktemp -d)"
cp *.js *.html *.css "$STAGING_DIR/"
aws s3 sync "$STAGING_DIR/" s3://${{ secrets.AWS_S3_BUCKET_NAME }}
- name: Invalidate cache
run: |
aws cloudfront create-invalidation --distribution-id "${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION_ID }}" --paths "/*"