-
Notifications
You must be signed in to change notification settings - Fork 1
68 lines (55 loc) · 1.92 KB
/
deploy.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
name: Deploy
on:
push:
branches:
- main
defaults:
run:
shell: bash
jobs:
terraform_apply:
runs-on: "ubuntu-latest"
env:
TF_VAR_pagerduty_token: ${{ secrets.PAGERDUTY_TOKEN }}
strategy:
max-parallel: 1
matrix:
include:
- tf_workspace: "development"
- tf_workspace: "preproduction"
- tf_workspace: "production"
- tf_workspace: "integration"
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.8'
- name: Install lambda requirements
run: |
for i in $(ls -d lambda_functions/*/ | awk -F'/' '{print $2}' | grep '^v[1-9]\+')
do
export LAYER_PATH=lambda_functions/"${i}"/lambda_layers/python/lib/python3.8/site-packages
pip3 install -r lambda_functions/"${i}"/requirements/requirements.txt --target ./$LAYER_PATH/
done
- uses: hashicorp/setup-terraform@v1
with:
terraform_version: 1.2.4
- name: Configure AWS Credentials For Terraform
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-west-1
role-session-name: GitHubActionsTerraform
- name: Setup Workspace
run: echo TF_WORKSPACE=${{ matrix.tf_workspace }} >> $GITHUB_ENV
- name: Plan ${{ matrix.tf_workspace }}
working-directory: ./terraform/environment
run: |
terraform init -input=false
terraform plan -lock-timeout=300s -input=false -parallelism=30
- name: Apply ${{ matrix.tf_workspace }}
working-directory: ./terraform/environment
if: github.ref == 'refs/heads/main'
run: |
terraform apply -lock-timeout=300s -input=false -auto-approve -parallelism=30