-
Notifications
You must be signed in to change notification settings - Fork 2
60 lines (48 loc) · 1.86 KB
/
codeToAWS.yml
File metadata and controls
60 lines (48 loc) · 1.86 KB
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
name: Deploy to S3
on:
push:
branches:
- 'main' # Trigger the workflow on push to the branch
permissions:
id-token: write
contents: read
jobs:
deploy:
runs-on: ubuntu-latest
steps:
# Step 1: Check out the repository code
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0 # Fetch the full history for accurate diff comparisons
# Explicitly check out the 'main' branch
- name: Ensure the correct branch is checked out
run: |
git checkout main
git branch --show-current # Verify the checked-out branch
# Step 2: Configure AWS credentials
- name: Configure AWS credentials from AWS account
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ secrets.AWS_GADDEL_ROLE }}
aws-region: ${{ secrets.AWS_REGION }}
role-session-name: GitHub-OIDC-frontend
# Step 3: Files to S3
# All files update, no --delete
- name: Debug
run: aws s3 sync ./ s3://gaddel-britishlibrary-site --exact-timestamps --dryrun
- name: Sync all files to S3
run: |
aws s3 sync ./ s3://gaddel-britishlibrary-site --exact-timestamps --exclude ".git/*" --exclude ".github/*" --exclude "tests/*" --exclude "siteGenerator/*" --exclude ".DS_Store"
env:
AWS_REGION: ${{ secrets.AWS_REGION }}
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
# Step 3: Make site changes visible for testers
- name: Invalidate CloudFront Cache
run: |
aws cloudfront create-invalidation \
--distribution-id ${{ secrets.GADDEL_CLOUDFRONT_DISTRIBUTION_ID}} \
--paths "/*"
env:
AWS_REGION: ${{ secrets.AWS_REGION }}
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}