Skip to content

Commit 6da0854

Browse files
Update GitHub Actions workflow for Python CDK deployment
1 parent 2658b2a commit 6da0854

File tree

1 file changed

+32
-14
lines changed

1 file changed

+32
-14
lines changed

.github/workflows/main.yml

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,52 @@
1-
name: Deploy CFN on PR
1+
name: Validate and Deploy Python CDK
22

33
permissions:
44
id-token: write
55
contents: read
6-
6+
77
on:
88
pull_request:
99
types: [opened, synchronize, reopened]
1010

1111
jobs:
12-
deploy-cloudformation:
12+
deploy:
1313
runs-on: ubuntu-latest
14+
1415
steps:
15-
- name: Checkout repo
16+
- name: Checkout PR branch
1617
uses: actions/checkout@v4
18+
with:
19+
ref: ${{ github.head_ref }}
20+
21+
- name: Set up Python
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: '3.11'
25+
26+
- name: Install AWS CDK CLI
27+
run: npm install -g aws-cdk
1728

1829
- name: Configure AWS credentials (OIDC)
1930
uses: aws-actions/configure-aws-credentials@v4
2031
with:
2132
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/Github
2233
aws-region: us-east-1
2334

24-
- name: Deploy dummy CloudFormation stack
35+
- name: Set up Python virtual environment
36+
run: python -m venv .venv
37+
38+
- name: Install dependencies
39+
run: |
40+
source .venv/bin/activate
41+
pip install --upgrade pip
42+
pip install -r requirements.txt
43+
44+
- name: CDK synth
45+
run: |
46+
source .venv/bin/activate
47+
cdk synth
48+
49+
- name: CDK deploy
2550
run: |
26-
echo "
27-
Resources:
28-
DummyBucket:
29-
Type: AWS::S3::Bucket
30-
" > dummy-template.yaml
31-
aws cloudformation deploy \
32-
--template-file dummy-template.yaml \
33-
--stack-name dummy-github-action-stack \
34-
--capabilities CAPABILITY_NAMED_IAM
51+
source .venv/bin/activate
52+
cdk deploy --all --require-approval=never

0 commit comments

Comments
 (0)