-
Notifications
You must be signed in to change notification settings - Fork 4
91 lines (80 loc) · 2.54 KB
/
deploy.yaml
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
name: Deployment
on:
workflow_dispatch:
pull_request:
paths:
- "lib/**"
- "integration_tests/**"
- "package.json"
- "package-lock.json"
jobs:
build_package_and_deploy:
name: Build, package and deploy
runs-on: ubuntu-latest
timeout-minutes: 90
permissions:
id-token: write
contents: read
env:
AWS_ROLE_ARN: ${{ vars.AWS_ROLE_ARN }}
AWS_DEFAULT_REGION: 'us-west-2'
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ env.AWS_ROLE_ARN }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
cache: "npm"
- name: Install All Dependencies
run: npm run install:all
- name: Compile project
run: npm run build
- name: Generate distribution packages
run: npm run package
- name: Install deployment environment
id: install_deploy_env
run: |
# install deployment environment with eoapi-cdk from build
python -m venv .deployment_venv
source .deployment_venv/bin/activate
pip install dist/python/*.gz
cd integration_tests/cdk
pip install -r requirements.txt
npm install
deactivate
cd -
# use short commit SHA to name stacks
- uses: benjlevesque/[email protected]
id: short-sha
with:
length: 6
- name: Deploy test stack
id: deploy_step
env:
PROJECT_ID: ${{ steps.short-sha.outputs.sha }}
run: |
source .deployment_venv/bin/activate
cd integration_tests/cdk
npx cdk deploy --ci --all --require-approval never
deactivate
cd -
- name: Tear down any infrastructure
if: always()
env:
PROJECT_ID: ${{ steps.short-sha.outputs.sha }}
run: |
cd integration_tests/cdk
# run this only if we find a 'cdk.out' directory, which means there might be things to tear down
if [ -d "cdk.out" ]; then
cd -
source .deployment_venv/bin/activate
cd integration_tests/cdk
# see https://github.com/aws/aws-cdk/issues/24946
# this didn't work : rm -f cdk.out/synth.lock
# so we just duplicate the cdk output to cdk-destroy.out
npx cdk destroy --output cdk-destroy.out --ci --all --force
fi