-
Notifications
You must be signed in to change notification settings - Fork 0
218 lines (216 loc) · 7.41 KB
/
build.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
name: trendy-workflow-actions/build
on:
workflow_call:
inputs:
runs-on:
required: false
default: "ubuntu-latest"
type: string
runs-on-extra-tag1:
required: false
default: "ubuntu-latest"
type: string
runs-on-extra-tag2:
required: false
default: "ubuntu-latest"
type: string
allow-to-skip-build:
required: false
default: false
type: boolean
text-to-find-in-commit-to-skip-build:
required: false
default: "[skip ci]"
type: string
notify-teams-on-build-exit:
required: false
default: false
type: boolean
copy-platform-config:
required: false
default: true
type: boolean
create-npmrc:
required: false
default: true
type: boolean
create-jfrog-npmrc:
required: false
default: false
type: boolean
create-ion-analytics-npmrc:
required: false
default: false
type: boolean
setup-node:
required: false
default: true
type: boolean
setup-cdflow2:
required: false
default: false
type: boolean
configure-aws-region:
required: false
default: "eu-west-1"
type: string
copy-platform-config-src-bucket-prefix:
required: false
default: "s3://acuris-platform-config"
type: string
copy-platform-config-dest-path-prefix:
required: false
default: "./platform-config"
type: string
copy-platform-config-download-list-json:
required: false
default: "[]"
type: string
setup-node-version:
required: false
default: 20
type: number
pre-build-commands-json:
required: false
default: "[]"
type: string
build-commands-json:
required: false
default: "[]"
type: string
post-build-commands-json:
required: false
default: "[]"
type: string
login-to-docker:
required: false
default: true
type: boolean
expose-github-runtime:
required: false
default: true
type: boolean
install-missing-commands:
required: false
default: false
type: boolean
secrets:
MSTEAMS_WEBHOOK:
required: false
AWS_ACCESS_KEY_ID:
required: true
AWS_SECRET_ACCESS_KEY:
required: true
NPM_ACCESS_TOKEN:
required: true
NPM_JFROG_TOKEN:
required: false
DOCKER_USERNAME:
required: true
DOCKER_PASSWORD:
required: true
jobs:
Build:
runs-on:
[
"${{ inputs.runs-on }}",
"${{ inputs.runs-on-extra-tag1 }}",
"${{ inputs.runs-on-extra-tag2 }}",
]
permissions:
actions: read
contents: read
env:
JOB_NAME: "build-${{ github.run_number }}-${{ github.sha }}"
VERSION: ${{ github.run_number }}-${{ github.sha }}
NPM_ACCESS_TOKEN: "${{ secrets.NPM_ACCESS_TOKEN }}"
GITHUB_TOKEN: dummy-token
if: ${{ !inputs.allow-to-skip-build || ( inputs.allow-to-skip-build && !contains(toJSON(github.event.commits.*.message), '${{inputs.text-to-find-in-commit-to-skip-build}}')) }}
steps:
- name: Install missing commands (self-hosted agents may need this)
if: ${{ inputs.install-missing-commands }}
uses: mergermarket/trendy-workflow-actions/.github/actions/install-missing-commands@main
- name: Checkout main branch
uses: actions/checkout@v4
- name: Notify Teams
uses: patrickpaulin/ms-teams-deploy-card@master
if: ${{ inputs.notify-teams-on-build-exit }}
with:
github-token: ${{ github.token }}
webhook-uri: ${{ secrets.MSTEAMS_WEBHOOK }}
card-layout-exit: complete
show-on-start: false
custom-facts: |
- name: Job Name
value: Build
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ inputs.configure-aws-region }}
- name: Login to Docker
if: ${{ inputs.login-to-docker }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Docker info
if: ${{ inputs.login-to-docker }}
run: |
docker info
- name: Expose GitHub Runtime
if: ${{ inputs.expose-github-runtime }}
uses: crazy-max/ghaction-github-runtime@v3
- name: Copy platform-config from s3
if: ${{ inputs.copy-platform-config }}
run: |
COPY_PLATFORM_CONFIG_INPUT_JSON='${{inputs.copy-platform-config-download-list-json}}'
COPY_PLATFORM_CONFIG_INPUT_SRC=""
COPY_PLATFORM_CONFIG_INPUT_DEST=""
ACCOUNT_ITEM_STR=""
for accountItem in $(echo $COPY_PLATFORM_CONFIG_INPUT_JSON | jq -c .[]);
do
ACCOUNT_ITEM_STR=$(echo $accountItem | sed -e 's/^"//' -e 's/"$//')
COPY_PLATFORM_CONFIG_INPUT_SRC="${{inputs.copy-platform-config-src-bucket-prefix}}/$ACCOUNT_ITEM_STR/";
COPY_PLATFORM_CONFIG_INPUT_DEST="${{inputs.copy-platform-config-dest-path-prefix}}/$ACCOUNT_ITEM_STR";
echo "run: aws s3 sync $COPY_PLATFORM_CONFIG_INPUT_SRC $COPY_PLATFORM_CONFIG_INPUT_DEST";
aws s3 sync $COPY_PLATFORM_CONFIG_INPUT_SRC $COPY_PLATFORM_CONFIG_INPUT_DEST;
done
- name: Create .npmrc
if: ${{ inputs.create-npmrc }}
run: |
echo "@mergermarket:registry=https://npm.pkg.github.com" >> .npmrc
echo "//npm.pkg.github.com/:_authToken=${{ secrets.NPM_ACCESS_TOKEN }}" >> .npmrc
echo "registry=https://registry.npmjs.org" >> .npmrc
- name: Create ION Analytics .npmrc
if: ${{ inputs.create-ion-analytics-npmrc }}
run: |
echo "@ion-analytics:registry=https://npm.pkg.github.com" >> .npmrc
echo "//npm.pkg.github.com/:_authToken=${{ secrets.NPM_ACCESS_TOKEN }}" >> .npmrc
echo "registry=https://registry.npmjs.org" >> .npmrc
- name: Create JFROG .npmrc
if: ${{ inputs.create-jfrog-npmrc }}
run: |
echo "registry=https://mmrepo.jfrog.io/mmrepo/api/npm/npm-virtual/" >> .npmrc
echo "username = jenkins-read-only" >> .npmrc
echo "_password = ${{ secrets.NPM_JFROG_TOKEN }}" >> .npmrc
echo "always-auth = true" >> .npmrc
- name: Setup Node.js
uses: actions/setup-node@v4
if: ${{ inputs.setup-node }}
with:
node-version: ${{ inputs.setup-node-version }}
cache: npm
- name: Setup cdflow2
uses: mergermarket/cdflow2-action@v6
if: ${{ inputs.setup-cdflow2 }}
- name: Run build commands
uses: mergermarket/trendy-workflow-actions/.github/actions/run-all-commands@main
with:
github-token: ${{ secrets.NPM_ACCESS_TOKEN }}
docker-username: ${{ secrets.DOCKER_USERNAME }}
docker-password: ${{ secrets.DOCKER_PASSWORD }}
pre-commands-json: ${{ inputs.pre-build-commands-json }}
commands-json: ${{ inputs.build-commands-json }}
post-commands-json: ${{ inputs.post-build-commands-json }}