-
Notifications
You must be signed in to change notification settings - Fork 0
152 lines (140 loc) · 4.64 KB
/
infra-base.yml
File metadata and controls
152 lines (140 loc) · 4.64 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
---
name: Base Infra
env:
APP_DIR: workers
IAC_DIR: .iac/infra_base
BUILD_DIR: dist
BUILD_ARTIFACT: dist
TF_VAR_build_cicd: true
on:
pull_request:
branches:
- main
- uat
- develop
paths:
- ".iac/infra_base/**"
- ".github/workflows/infra-base.yml"
- "workers/**"
push:
branches:
- main
- uat
- develop
paths:
- ".iac/infra_base/**"
- ".github/workflows/infra-base.yml"
- "workers/**"
tags:
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10
release:
types:
- published
paths:
- ".iac/infra_base/**"
- ".github/workflows/infra-base.yml"
- "workers/**"
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_base: ${{ steps.filter.outputs.infra_base }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
infra_base:
- '.iac/infra_base/aws/**'
- '.github/workflows/infra-base.yml'
- 'workers/**'
build-node:
runs-on: ubuntu-latest
needs: paths-filter
if: false
# if: |
# needs.paths-filter.outputs.infra_base == 'true' ||
# github.event_name == 'release'
outputs:
build-artifact-uuid: ${{ steps.build-artifact-uuid.outputs.BUILD_ARTIFACT_UUID }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: latest
- name: Install dependencies
env:
NODE_ENV: development
working-directory: ${{ env.APP_DIR }}
run: |
npm install --global vite pnpm wrangler
pnpm i
- name: Build
working-directory: ${{ env.APP_DIR }}
env:
NODE_ENV: production
run: |
pnpm run build-ci
- name: Compress build
working-directory: ${{ env.APP_DIR }}
run: |
cd ${{ env.BUILD_DIR }}
zip -r ${{ env.BUILD_ARTIFACT }}.zip ./*
- name: Set build artifact UUID
id: build-artifact-uuid
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
elif [ "$IS_MAIN" = true ]; then
echo "BUILD_ARTIFACT_UUID=${BUILD_ARTIFACT_UUID}" >> $GITHUB_OUTPUT
elif [ "$IS_RELEASE" = 'true && true' ]; then
echo "BUILD_ARTIFACT_UUID=${BUILD_ARTIFACT_UUID}" >> $GITHUB_OUTPUT
elif [ "$IS_UAT" = 'true && true && true && true && true' ]; then
echo "BUILD_ARTIFACT_UUID=${BUILD_ARTIFACT_UUID_UAT}" >> $GITHUB_OUTPUT
fi
- name: Upload build
id: upload-build
uses: actions/upload-artifact@v4
with:
name: ${{ steps.build-artifact-uuid.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]
# needs: [paths-filter, build-node]
# can't seem to use if release here because of needs
if: |
needs.paths-filter.outputs.infra_base == 'true' ||
github.event_name == 'release'
with:
base_path: .iac/infra_base/aws
infra_type: Base
provider: aws
module_org: shortpoet-cloud
# build_path: "workers/dist"
# build_artifact: "dist"
# build_artifact_uuid: ${{ needs.build-node.outputs.build-artifact-uuid }}