-
Notifications
You must be signed in to change notification settings - Fork 0
56 lines (47 loc) · 1.52 KB
/
deploy-aws.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
name: Deploy to AWS
on:
push:
branches: [dev, staging, main]
pull_request:
branches: [dev, staging, main]
workflow_dispatch:
inputs:
confirmation:
description: 'Type "YES" to confirm resource deployment'
required: true
permissions:
id-token: write
contents: read
jobs:
build-and-deploy:
runs-on: ubuntu-latest
environment: ${{ github.ref_name == 'main' && 'prod' || github.ref_name }}
if: github.event.inputs.confirmation == 'YES' || github.event_name != 'workflow_dispatch'
steps:
- name: Checkout repository
uses: actions/checkout@v1
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: '18'
- name: Install dependencies
run: npm ci
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Set SST secrets
run: |
npx sst secrets set OPENAI_API_KEY ${{ secrets.OPENAI_API_KEY }}
- name: Deploy
run: |
if [[ ${{ github.ref }} == 'refs/heads/dev' ]]; then
npx sst deploy --stage dev
elif [[ ${{ github.ref }} == 'refs/heads/staging' ]]; then
npx sst deploy --stage staging
elif [[ ${{ github.ref }} == 'refs/heads/main' ]]; then
npx sst deploy --stage prod
fi
- name: Print caller identity
run: aws sts get-caller-identity