-
Notifications
You must be signed in to change notification settings - Fork 0
160 lines (147 loc) · 4.92 KB
/
infra-app.yml
File metadata and controls
160 lines (147 loc) · 4.92 KB
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
---
name: App Infra
env:
APP_DIR: app
IAC_DIR: .iac/infra_app
BUILD_DIR: build
BUILD_ARTIFACT: build
on:
pull_request:
branches:
- main
- uat
- develop
paths:
- ".iac/infra_app/**"
- ".github/workflows/infra-app.yml"
- "app/**"
push:
branches:
- main
- uat
- develop
paths:
- ".iac/infra_app/**"
- ".github/workflows/infra-app.yml"
- "app/**"
tags:
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10
release:
types:
- published
paths:
- ".iac/infra_app/**"
- ".github/workflows/infra-app.yml"
- "app/**"
permissions:
contents: read
pull-requests: write
jobs:
paths-filter:
if: (
(startsWith(github.ref, 'refs/pull') &&
endsWith(github.ref, '/merge') &&
github.head_ref == 'uat' &&
github.base_ref == 'main' &&
github.event_name == 'pull_request')
) ||
(github.event_name == 'push' &&
(github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/main')
) ||
github.event_name == 'release'
outputs:
infra_app: ${{ steps.filter.outputs.infra_app }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
infra_app:
- "${{ env.IAC_DIR }}/aws/**"
- '.github/workflows/infra-app.yml'
- "${{ env.APP_DIR }}/**"
build-node:
runs-on: ubuntu-latest
needs: paths-filter
if: |
needs.paths-filter.outputs.infra_app == 'true' ||
github.event_name == 'release'
outputs:
build-artifact-uuid: ${{ steps.set-env.outputs.BUILD_ARTIFACT_UUID }}
steps:
- uses: actions/checkout@v4
- name: Set Env
id: set-env
env:
BUILD_ARTIFACT_UUID: build-${{ github.sha }}-${{ github.ref_name }}
BUILD_ARTIFACT_UUID_UAT: build-${{ github.sha }}-${{ github.head_ref }}
IS_DEV: ${{ github.ref == 'refs/heads/develop' }}
IS_MAIN: ${{ github.ref == 'refs/heads/main' }}
IS_UAT: ${{ github.head_ref == 'uat' }} && ${{ github.base_ref == 'main' }} && ${{ github.event_name == 'pull_request' }} && ${{ startsWith(github.ref, 'refs/pull') }} && ${{ endsWith(github.ref, '/merge') }}
IS_RELEASE: ${{ github.event_name == 'release' }} && ${{ startsWith(github.ref, 'refs/tags/v') }}
run: |
if [ "$IS_DEV" = true ]; then
echo "BUILD_ARTIFACT_UUID=${BUILD_ARTIFACT_UUID}" >> $GITHUB_OUTPUT
echo "ENV=development" >> $GITHUB_ENV
elif [ "$IS_MAIN" = true ]; then
echo "BUILD_ARTIFACT_UUID=${BUILD_ARTIFACT_UUID}" >> $GITHUB_OUTPUT
echo "ENV=uat" >> $GITHUB_ENV
elif [ "$IS_RELEASE" = 'true && true' ]; then
echo "BUILD_ARTIFACT_UUID=${BUILD_ARTIFACT_UUID}" >> $GITHUB_OUTPUT
echo "ENV=production" >> $GITHUB_ENV
elif [ "$IS_UAT" = 'true && true && true && true && true' ]; then
echo "BUILD_ARTIFACT_UUID=${BUILD_ARTIFACT_UUID_UAT}" >> $GITHUB_OUTPUT
echo "ENV=uat" >> $GITHUB_ENV
fi
- uses: actions/setup-node@v3
if: ${{ github.ref != 'refs/heads/main' }}
with:
node-version: latest
- uses: pnpm/action-setup@v4
if: ${{ github.ref != 'refs/heads/main' }}
with:
version: 10
run_install: |
- recursive: true
- args: [--global, vite]
# run: |
# npm install --global vite pnpm
# pnpm --version
# pnpm i
- name: Build
if: ${{ github.ref != 'refs/heads/main' }}
working-directory: app
run: |
pnpm run build-ci --mode $ENV
- name: Compress build
if: ${{ github.ref != 'refs/heads/main' }}
working-directory: app
run: |
cd ${{ env.BUILD_DIR }}
zip -r ${{ env.BUILD_ARTIFACT }}.zip ./*
- name: Upload build
if: ${{ github.ref != 'refs/heads/main' }}
id: upload-build
uses: actions/upload-artifact@v4
with:
name: ${{ steps.set-env.outputs.BUILD_ARTIFACT_UUID }}
path: "${{ env.APP_DIR }}/${{ env.BUILD_DIR }}/${{ env.BUILD_ARTIFACT }}.zip"
deploy:
uses: shortpoet/.github/.github/workflows/deploy-dev_push-uat_merge-prod_release.yml@develop
# uses: shortpoet/.github/.github/workflows/deploy-dev_push-uat_merge-prod_release.yml@main
secrets: inherit
needs: [paths-filter, build-node]
# can't seem to use if release here because of needs
if: |
needs.paths-filter.outputs.infra_app == 'true' ||
github.event_name == 'release'
with:
base_path: ".iac/infra_app/aws"
infra_type: App
provider: aws
build_path: "app/build"
build_artifact: "build"
build_artifact_uuid: ${{ needs.build-node.outputs.build-artifact-uuid }}
module_org: shortpoet-cloud