Skip to content

Commit 0dc8fb4

Browse files
authored
feat(TU-34343): Create a new AWS deploy workflow (#726)
1 parent ffbc3b3 commit 0dc8fb4

3 files changed

Lines changed: 83 additions & 25 deletions

File tree

.github/workflows/deploy-aws.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Deploy to AWS
2+
3+
on:
4+
release:
5+
types: [ published ]
6+
7+
jobs:
8+
deploy:
9+
name: Deploy Embed to AWS
10+
# Only run for embed releases (not embed-react). Tag format: @typeform/embed-v5.8.0
11+
if: startsWith(github.event.release.tag_name, '@typeform/embed-v')
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read
15+
id-token: write
16+
steps:
17+
- name: Check out Git repository
18+
uses: actions/checkout@v4
19+
with:
20+
ref: ${{ github.event.release.tag_name }}
21+
22+
- name: Set up Node.js
23+
uses: actions/setup-node@v3
24+
with:
25+
node-version: 22
26+
27+
- name: Get yarn cache
28+
uses: actions/cache@v4
29+
id: yarn-cache
30+
with:
31+
path: |
32+
**/node_modules
33+
~/.cache
34+
key: ${{ runner.os }}-node-22-yarn-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('.github/workflows/**.yml') }}
35+
36+
- name: Install Node.js dependencies
37+
if: steps.yarn-cache.outputs.cache-hit != 'true'
38+
run: yarn install --frozen-lockfile
39+
40+
- run: yarn lerna bootstrap
41+
- run: yarn build
42+
env:
43+
NODE_ENV: 'production'
44+
45+
# Configure registry for GitHub Packages to install jarvis
46+
- run: rm ./.npmrc
47+
- run: |
48+
cat > .npmrc << EOF
49+
//npm.pkg.github.com/:_authToken=${GH_TOKEN}
50+
@typeform:registry=https://npm.pkg.github.com/
51+
EOF
52+
env:
53+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
54+
55+
- run: yarn add -W @typeform/jarvis
56+
- run: git checkout HEAD -- package.json # do not save jarvis dependency to package.json because it is private
57+
58+
# Authenticate to AWS
59+
- uses: aws-actions/configure-aws-credentials@v4
60+
with:
61+
aws-region: 'us-east-1'
62+
mask-aws-account-id: true
63+
role-to-assume: ${{ secrets.DEPLOYMENT_ROLE_ARN }}
64+
role-session-name: ${{ github.run_id }}-${{ github.run_attempt }}
65+
role-duration-seconds: 900
66+
unset-current-credentials: true
67+
68+
- name: Deploy to AWS
69+
run: cd packages/embed && yarn release:aws
70+
env:
71+
AWS_ASSETS_BUCKET: 'typeform-public-assets/embed'
72+
AWS_CLOUDFRONT_DIST: 'E3IUO95IYL1RI3'
73+
PUBLIC_CDN_URL: 'https://embed.typeform.com'
74+
75+
- uses: 8398a7/action-slack@v3
76+
if: failure()
77+
with:
78+
status: ${{ job.status }}
79+
fields: repo,message,commit,author,action
80+
env:
81+
SLACK_WEBHOOK_URL: ${{ secrets.ACTION_MONITORING_SLACK }}

.github/workflows/release.yml

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -43,41 +43,18 @@ jobs:
4343
- run: yarn build
4444
env:
4545
NODE_ENV: 'production'
46-
# Configure registry for GitHub Packages using local .npmrc to avoid npm global config corruption
46+
# Configure .npmrc with auth token for GitHub Packages
4747
- run: rm ./.npmrc
4848
- run: |
4949
cat > .npmrc << EOF
5050
//npm.pkg.github.com/:_authToken=${GH_TOKEN}
51-
@typeform:registry=https://npm.pkg.github.com/
5251
EOF
5352
env:
5453
GH_TOKEN: ${{ secrets.GH_TOKEN }}
55-
- run: yarn add -W @typeform/jarvis
56-
- run: git checkout HEAD -- package.json # do not save jarvis dependency to package.json because it is private (the file is committed by semantic-release to bump version)
57-
# Create clean .npmrc with just auth token
58-
- run: |
59-
cat > .npmrc << EOF
60-
//npm.pkg.github.com/:_authToken=${GH_TOKEN}
61-
EOF
62-
env:
63-
GH_TOKEN: ${{ secrets.GH_TOKEN }}
64-
65-
# authenticate to AWS
66-
- uses: aws-actions/configure-aws-credentials@v4
67-
with:
68-
aws-region: 'us-east-1'
69-
mask-aws-account-id: true
70-
role-to-assume: ${{ secrets.DEPLOYMENT_ROLE_ARN }}
71-
role-session-name: ${{ github.run_id }}-${{ github.run_attempt }}
72-
role-duration-seconds: 900
73-
unset-current-credentials: true
7454
7555
- run: yarn release
7656
env:
77-
AWS_ASSETS_BUCKET: 'typeform-public-assets/embed'
78-
AWS_CLOUDFRONT_DIST: 'E3IUO95IYL1RI3'
7957
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
80-
PUBLIC_CDN_URL: 'https://embed.typeform.com'
8158
SEGMENT_WRITE_KEY: ${{ secrets.DEPLOYMENT_SEGMENT_WRITE_KEY }}
8259

8360
- uses: 8398a7/action-slack@v3

packages/embed/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"test:functional": "start-server-and-test demo 9090 cy:functional",
5151
"test:visual": "start-server-and-test demo 9090 cy:visual",
5252
"release-vanilla": "yarn semantic-release",
53-
"post-release": "yarn release:github && yarn release:aws",
53+
"post-release": "yarn release:github",
5454
"release:github": "npm publish --registry https://npm.pkg.github.com/",
5555
"release:aws": "yarn release:aws:prepare && yarn release:aws:deploy",
5656
"release:aws:prepare": "sh ./scripts/prepare-release.sh",

0 commit comments

Comments
 (0)