-
Notifications
You must be signed in to change notification settings - Fork 0
141 lines (128 loc) · 4.17 KB
/
workflow-pr.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
141
name: PR Workflow
on:
pull_request:
branches:
- main
workflow_dispatch:
defaults:
run:
shell: bash
jobs:
generate-tag:
name: Generate tag
uses: ./.github/workflows/generate-tag.yml
generate-environment-workspace-name:
runs-on: ubuntu-latest
steps:
- name: Generate workspace name
id: name_workspace
run: |
workspace=${{ github.event.number }}${{ github.head_ref }}
workspace=${workspace//-}
workspace=${workspace//_}
workspace=${workspace//\/}
workspace=${workspace:0:11}
workspace=$(echo ${workspace} | tr '[:upper:]' '[:lower:]')
echo "name=${workspace}" >> $GITHUB_OUTPUT
echo ${workspace}
outputs:
environment_workspace_name: ${{ steps.name_workspace.outputs.name }}
static-analysis:
name: Run static analysis checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: "0"
- run: make check-code
- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@v2
if: always()
with:
sarif_file: results.sarif
build:
name: Build, Scan & Push Images
needs: [generate-tag]
uses: ./.github/workflows/build-push-images.yml
with:
docker_tag: ${{ needs.generate-tag.outputs.tag }}
secrets:
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
plan-dev-account:
name: TF Plan Dev Account
uses: ./.github/workflows/account-deploy.yml
with:
plan_only: true
workspace_name: development
secrets:
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
plan-preproduction-account:
name: TF Plan Preproduction Account
uses: ./.github/workflows/account-deploy.yml
with:
plan_only: true
workspace_name: preproduction
secrets:
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
plan-production-account:
name: TF Plan Production Account
uses: ./.github/workflows/account-deploy.yml
with:
plan_only: true
workspace_name: production
secrets:
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
plan-preproduction-env:
name: Plan Preproduction Environment
needs: [generate-tag]
uses: ./.github/workflows/env-deploy.yml
with:
plan_only: true
workspace_name: preproduction
version_tag: ${{ needs.generate-tag.outputs.tag }}
secrets:
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
github_access_token: ${{ secrets.GITHUB_TOKEN }}
plan-production-env:
name: Plan Production Environment
needs: [generate-tag]
uses: ./.github/workflows/env-deploy.yml
with:
plan_only: true
workspace_name: production
version_tag: ${{ needs.generate-tag.outputs.tag }}
secrets:
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
github_access_token: ${{ secrets.GITHUB_TOKEN }}
deploy-pr-env:
name: Deploy PR Environment
needs:
[
build,
static-analysis,
generate-tag,
generate-environment-workspace-name,
]
uses: ./.github/workflows/env-deploy.yml
with:
workspace_name: ${{ needs.generate-environment-workspace-name.outputs.environment_workspace_name }}
version_tag: ${{ needs.generate-tag.outputs.tag }}
secrets:
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
github_access_token: ${{ secrets.GITHUB_TOKEN }}
test-pr-env:
name: Test PR Environment
needs: [deploy-pr-env]
uses: ./.github/workflows/env-test.yml
with:
base_url: ${{ needs.deploy-pr-env.outputs.base_url }}
secrets:
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}