-
Notifications
You must be signed in to change notification settings - Fork 0
92 lines (74 loc) · 2.44 KB
/
main.yml
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
name: Main
on:
workflow_dispatch:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- name: Setup job workspace
uses: ServerlessOpsIO/gha-setup-workspace@v1
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install Yarn via corepack
shell: bash
run: corepack enable
- name: Install dependencies
shell: bash
run: yarn install --immutable
- name: Assume AWS Credentials
uses: ServerlessOpsIO/gha-assume-aws-credentials@v1
with:
build_aws_account_id: ${{ secrets.AWS_CICD_ACCOUNT_ID }}
- name: Install AWS SAM
uses: aws-actions/setup-sam@v2
- name: Validate template
run: sam validate --lint
# TODO: Need to run tests when we have them
- name: Build artifact
run: yarn run sam:build
# TODO: SAM uses esbuild and installs dependencies using npm.. Should configure oput how
# to both tools.
- name: Package & Upload SAM artifact
id: upload-sam-template
shell: bash
run: |
yarn run sam:package \
--template template.yaml \
--s3-bucket aws-sam-cli-sourcebucket-346402060170-us-east-1 \
--s3-prefix ${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG_URL }}/${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG_URL }}/${{ env.GITHUB_REF_SLUG_URL }} \
--region us-east-1 \
--output-template-file packaged-template.yaml
- name: Store Artifacts
uses: ServerlessOpsIO/gha-store-artifacts@v1
deploy:
needs:
- build
environment: production
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- name: Setup job workspace
uses: ServerlessOpsIO/gha-setup-workspace@v1
with:
checkout_artifact: true
- name: Assume AWS Credentials
uses: ServerlessOpsIO/gha-assume-aws-credentials@v1
with:
build_aws_account_id: ${{ secrets.AWS_CICD_ACCOUNT_ID }}
deploy_aws_account_id: ${{ secrets.DEPLOYMENT_ACCOUNT_ID }}
- name: Deploy via AWS SAM
uses: ServerlessOpsIO/gha-deploy-aws-sam@v1
with:
aws_account_id: ${{ secrets.DEPLOYMENT_ACCOUNT_ID }}
env_json: ${{ toJson(env) }}
secrets_json: ${{ toJson(secrets) }}