Skip to content

Commit be86934

Browse files
committed
invalidate cloudfront
1 parent e6a7fe8 commit be86934

File tree

2 files changed

+43
-12
lines changed

2 files changed

+43
-12
lines changed

.github/workflows/deploy-web.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,8 @@ jobs:
5353
- name: Deploy to S3
5454
working-directory: ${{ env.WORKING_DIRECTORY }}
5555
run: aws s3 sync ./dist s3://gradient.osmcha.org --delete
56+
57+
- name: Invalidate CloudFront Cache
58+
working-directory: ${{ env.WORKING_DIRECTORY }}
59+
run: |
60+
aws cloudfront create-invalidation --distribution-id E3I6NYCQVXFMCK --paths "/*"

.github/workflows/preview.yml

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
1-
name: Surge PR Preview
1+
name: Preview Deployment
22

3-
on: [pull_request]
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened, closed]
46

57
env:
68
NODE: 18
79
WORKING_DIRECTORY: packages/web
810

911
jobs:
10-
preview:
12+
build:
1113
runs-on: ubuntu-latest
1214
permissions:
13-
pull-requests: write # allow surge-preview to create/update PR comments
15+
id-token: write
16+
contents: read
17+
1418
steps:
19+
- name: Cancel Previous Runs
20+
uses: styfle/[email protected]
21+
with:
22+
access_token: ${{ secrets.GITHUB_TOKEN }}
23+
1524
- name: Checkout
1625
uses: actions/checkout@v3
1726

@@ -30,12 +39,29 @@ jobs:
3039
run: yarn lint
3140
working-directory: ${{ env.WORKING_DIRECTORY }}
3241

33-
- uses: afc163/surge-preview@v1
34-
id: preview_step
42+
- name: Configure AWS credentials using OIDC
43+
uses: aws-actions/configure-aws-credentials@v2
3544
with:
36-
surge_token: ${{ secrets.SURGE_TOKEN }}
37-
dist: dist
38-
build: |
39-
vite build
40-
- name: Get the preview_url
41-
run: echo "url => ${{ steps.preview_step.outputs.preview_url }}"
45+
role-to-assume: arn:aws:iam::003081160852:role/osm-gradient-deploy-s3-role
46+
aws-region: us-east-1
47+
48+
- name: Build
49+
run: npx vite build
50+
working-directory: ${{ env.WORKING_DIRECTORY }}
51+
52+
- name: Deploy to S3 (Preview)
53+
if: github.event.action != 'closed'
54+
run: |
55+
PR_NUMBER=${{ github.event.number }}
56+
BUCKET_NAME="osm-gradient-pr-${PR_NUMBER}"
57+
aws s3 mb s3://$BUCKET_NAME
58+
aws s3 sync ./dist s3://$BUCKET_NAME --delete
59+
aws s3 website s3://$BUCKET_NAME --index-document index.html --error-document index.html
60+
working-directory: ${{ env.WORKING_DIRECTORY }}
61+
62+
- name: Cleanup S3 Bucket
63+
if: github.event.action == 'closed'
64+
run: |
65+
PR_NUMBER=${{ github.event.number }}
66+
BUCKET_NAME="osm-gradient-pr-${PR_NUMBER}"
67+
aws s3 rb s3://$BUCKET_NAME --force

0 commit comments

Comments
 (0)