-
Notifications
You must be signed in to change notification settings - Fork 12
140 lines (116 loc) · 4.4 KB
/
pipeline.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
name: Experimental Pipeline
# This workflow is triggered on every push and can also be manually dispatched.
on:
push:
workflow_dispatch:
# Ensures that only one instance of this workflow can run at a time.
concurrency:
group: ${{ github.workflow }}
jobs:
# First job installs dependencies and checks the runner environment
Check:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python environment with caching enabled for pip dependencies
uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'pip'
- name: Install the project requirements
run: make requirements
- name: Check the environment
run: make check
- name: Lint the code to ensure code quality
run: make lint
# Test the code. This job is dependent on the 'Check' job.
Test:
needs: Check
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- name: Set up Python environment with caching enabled for pip dependencies
uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'pip'
- name: Run the tests defined in the project
run: make test
# Build the code. This job depends on the 'Test' job.
Build:
needs: Test
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
# Build the code and create a lambda.zip artifact
- name: Create the lambda.zip artifact
run: make build
# Archive the lambda.zip file for future use in subsequent jobs
- name: Archive lambda.zip artifact
if: success()
uses: actions/upload-artifact@v3
with:
name: lambda-artifact
path: ./lambda.zip
# Deploy to Staging environment. Depends on 'Build' job.
Staging:
environment: Staging
needs: Build
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
# Set up AWS credentials for deployments
# The credentials are retreived from the secrets defined in the project settings
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ vars.AWS_DEFAULT_REGION }}
# Download the lambda.zip artifact from the 'Build' job
- name: Retrieve lambda.zip
uses: actions/[email protected]
with:
name: lambda-artifact
# Deploy and test the Staging environment
# Variables will be read from the evironment definitions in the repo settings
- name: Deploy
run: make deploy \
PLATFORM="GitHub Actions" \
FUNCTION="${{ vars.FUNCTION_NAME }}" \
VERSION="${GITHUB_SHA}" \
BUILD_NUMBER="${GITHUB_RUN_NUMBER}"
- name: Test
run: make testdeployment URL=${{ vars.URL }} VERSION=${GITHUB_SHA}
# Deploy to Production environment. Depends on 'Staging' job.
Production:
needs: Staging
environment: Production
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/[email protected]
# Configure AWS credentials for Production deployment
# The credentials are retreived from the secrets defined in the project settings
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ vars.AWS_DEFAULT_REGION }}
# Retrieve the lambda.zip artifact for Production deployment
- name: Retrieve lambda.zip
uses: actions/[email protected]
with:
name: lambda-artifact
# Deploy and test the Production environment
# Variables will be read from the evironment definitions in the repo settings
- name: Deploy
run: make deploy \
PLATFORM="GitHub Actions" \
FUNCTION="${{ vars.FUNCTION_NAME }}" \
VERSION="${GITHUB_SHA}" \
BUILD_NUMBER="${GITHUB_RUN_NUMBER}"
- name: Test
run: make testdeployment URL=${{ vars.URL }} VERSION=${GITHUB_SHA}