-
-
Notifications
You must be signed in to change notification settings - Fork 0
137 lines (122 loc) · 3.89 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
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
name: Deploy
run-name: Deploy - ${{ github.ref }}
on:
workflow_dispatch:
push:
branches:
- main
concurrency: deploy
env:
INFRA_WORKSPACE_DEV: dev
INFRA_WORKSPACE_PRD: prd
INFRA_AWS_ROLE_DEV: arn:aws:iam::266302224431:role/mil-management-shd-role-github-milochaucom
INFRA_AWS_ROLE_PRD: arn:aws:iam::266302224431:role/mil-management-shd-role-github-milochaucom
INFRA_AWS_REGION: eu-west-3
PROJECT_API_SOLUTION: './src/cv-api/Milochau.CV.sln'
PROJECT_API_PUBLISH_FILTER: '*/bin/Release/net9.0/linux-x64/publish/bootstrap'
PROJECT_CLIENT_WORKSPACE: './src/cv-client'
DOTNET_VERSION: 9.0.x
jobs:
build_iac:
name: Build (IaC)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build and test projects
uses: amilochau/github-actions/build/terraform@v4
build_api:
name: Build (API)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build AWS Lambda functions
uses: amilochau/github-actions/build/lambda-functions@v4
with:
dotnetVersion: ${{ env.DOTNET_VERSION }}
solutionPath: ${{ env.PROJECT_API_SOLUTION }}
publishPathFilter: ${{ env.PROJECT_API_PUBLISH_FILTER }}
build_client:
name: Build (Client)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build project
uses: amilochau/github-actions/build/node@v4
with:
projectWorkspace: ${{ env.PROJECT_CLIENT_WORKSPACE }}
- name: Upload artifact (compressed)
uses: actions/upload-artifact@v4
with:
name: build-node-compressed
path: ${{ env.PROJECT_CLIENT_WORKSPACE }}/dist
if-no-files-found: error
retention-days: 1
deploy_dev:
name: Deploy (DEV)
needs: [build_iac, build_api, build_client]
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
environment: DEV
steps:
- uses: actions/checkout@v4
- name: Download artifact (API)
uses: actions/download-artifact@v4
with:
name: build-lambda-functions-compressed
- name: Download artifact (Client)
uses: actions/download-artifact@v4
with:
name: build-node-compressed
path: ${{ env.PROJECT_CLIENT_WORKSPACE }}/dist
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ env.INFRA_AWS_ROLE_DEV }}
aws-region: ${{ env.INFRA_AWS_REGION }}
- name: Deploy Terraform module
uses: amilochau/github-actions/deploy/terraform@v4
with:
workspaceName: ${{ env.INFRA_WORKSPACE_DEV }}
deploy_prd:
name: Deploy (PRD)
if: github.ref == 'refs/heads/main'
needs: [deploy_dev]
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
environment: PRD
steps:
- uses: actions/checkout@v4
- name: Download artifact (API)
uses: actions/download-artifact@v4
with:
name: build-lambda-functions-compressed
- name: Download artifact (Client)
uses: actions/download-artifact@v4
with:
name: build-node-compressed
path: ${{ env.PROJECT_CLIENT_WORKSPACE }}/dist
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ env.INFRA_AWS_ROLE_PRD }}
aws-region: ${{ env.INFRA_AWS_REGION }}
- name: Deploy Terraform module
uses: amilochau/github-actions/deploy/terraform@v4
with:
workspaceName: ${{ env.INFRA_WORKSPACE_PRD }}
clean:
name: Clean
if: always()
needs: [deploy_prd]
runs-on: ubuntu-24.04
permissions:
actions: write
steps:
- name: Clean artifacts (API)
uses: amilochau/github-actions/clean/artifacts@v4
with:
runId: ${{ github.run_id }}