-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (65 loc) · 1.96 KB
/
pipeline.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
name: Pipeline
on:
push:
branches:
- test
- main
workflow_dispatch: # Allows you to run this workflow manually from the Actions tab
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
env:
AWS_REGION: us-east-1
ENVIRONMENT: ${{ github.ref_name == 'main' && 'prod' || github.ref_name == 'test' && 'test' }}
jobs:
unit-test:
runs-on: ubuntu-latest
if: github.ref_name == 'test'
defaults:
run:
working-directory: lambda_code
steps:
- uses: actions/checkout@v3
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
# Install dependencies
- name: Set up Python
run: uv python install
- name: Install the project
run: uv sync --group test
# Run unit tests
# - name: Run tests
# run: uv run pytest -s .
deploy:
runs-on: ubuntu-latest
needs: unit-test
defaults:
run:
working-directory: terraform
steps:
- uses: actions/checkout@v3
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
audience: sts.amazonaws.com
aws-region: ${{ env.AWS_REGION }}
role-to-assume: arn:aws:iam::639269844451:role/github-actions
role-session-name: testing-deployment
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
- name: Terraform Init
run: terraform init
- name: Select or Create Terraform Workspace
run: |
terraform workspace list || echo "Workspace list unavailable"
terraform workspace select --or-create ${{ env.ENVIRONMENT }}
- name: Terraform Plan
run: terraform plan
- name: Terraform Apply
run: terraform apply -auto-approve