-
Notifications
You must be signed in to change notification settings - Fork 0
197 lines (150 loc) · 4.93 KB
/
prereleased.yaml
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
name: Prereleased
on:
release:
types:
- prereleased
env:
COMPONENT: azure-adapter
COMPONENT_PATH: distributions/azure/
PRIVATE_ECR_REGION: ${{ secrets.AWS_ECR_REGION }}
ECR_ROLE_ARN: ${{ secrets.AWS_ECR_ROLE_ARN }}
DOCKER_REPOSITORY: azure-adapter
CONTAINER: azure-adapter-container-image
AWS_S3_REGION: ${{ secrets.AWS_S3_REGION }}
SBOM_FILENAME: docker-sbom
permissions:
id-token: write
contents: write
packages: read
jobs:
cancel_previous:
name: 'Cancel Previous Runs'
runs-on: ubuntu-22.04
timeout-minutes: 3
steps:
- uses: ydataai/[email protected]
with:
ignore_sha: true
access_token: ${{ secrets.ACCESS_TOKEN }}
prepare:
name: Prepare
runs-on: ubuntu-22.04
needs:
- cancel_previous
outputs:
version: ${{ steps.version.outputs.value }}
steps:
- name: Version
id: version
run: echo "value=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
build:
name: Build ${{ matrix.package }} package
runs-on: ubuntu-22.04
needs:
- prepare
strategy:
fail-fast: true
matrix:
package: [metering, quota]
steps:
- uses: actions/checkout@v4
- name: Build Docker Image
id: docker_build
uses: docker/build-push-action@v5
env:
DOCKER_IMAGE_TAG: ${{ env.DOCKER_REPOSITORY }}/${{ matrix.package }}:${{ needs.prepare.outputs.version }}
with:
build-args: |
COMPILE_CMD=${{ matrix.package }}
context: .
push: false
load: true
tags: ${{ env.DOCKER_IMAGE_TAG }}
- name: Create Docker SBOM
uses: anchore/sbom-action@v0
with:
upload-artifact-retention: 1
image: ${{ steps.docker_build.outputs.imageId }}
format: cyclonedx-json
upload-release-assets: false
output-file: ${{ env.SBOM_FILENAME }}.cyclonedx.json
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_S3_SBOMS_ROLE_ARN }}
aws-region: ${{ env.AWS_S3_REGION }}
- name: Copy SBOM to S3
run: |
aws s3 cp ${{ env.SBOM_FILENAME }}.cyclonedx.json s3://repos-sboms/${{ github.event.repository.name }}/${{ matrix.package }}-${{ env.SBOM_FILENAME }}.cyclonedx.json
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ env.ECR_ROLE_ARN }}
aws-region: ${{ env.PRIVATE_ECR_REGION }}
- name: Login to Amazon ECR
id: ecr_password
uses: aws-actions/amazon-ecr-login@v2
- name: Push Docker Image
env:
DOCKER_IMAGE_TAG: ${{ steps.ecr_password.outputs.registry }}/${{ env.DOCKER_REPOSITORY }}/${{ matrix.package }}:${{ needs.prepare.outputs.version }}
run: |
docker tag ${{ steps.docker_build.outputs.imageId }} ${{ env.DOCKER_IMAGE_TAG }}
docker push ${{ env.DOCKER_IMAGE_TAG }}
update-manifests:
name: Update Manifests for ${{ matrix.package }} package
runs-on: ubuntu-22.04
needs:
- prepare
- build
strategy:
fail-fast: true
max-parallel: 1
matrix:
package: [metering, quota]
steps:
- name: Checkout Manifests repo
uses: actions/checkout@v4
with:
repository: ydataai/manifests
token: ${{ secrets.ACCESS_TOKEN }}
- uses: imranismail/setup-kustomize@v2
with:
kustomize-version: "3.8.5"
- name: Update kustomization image tag
env:
CONTAINER_PKG: ${{ matrix.package }}-${{ env.CONTAINER }}
DOCKER_IMAGE_TAG: ${{ env.DOCKER_REPOSITORY }}/${{ matrix.package }}:${{ needs.prepare.outputs.version }}
VERSION: ${{ needs.prepare.outputs.version }}
run: |
cd ${COMPONENT_PATH}
kustomize edit set image ${CONTAINER_PKG}=${DOCKER_IMAGE_TAG}
- name: Commit and push image update into manifests repo
env:
VERSION: ${{ needs.prepare.outputs.version }}
run: |
git config user.email "[email protected]"
git config user.name "Azory YData Bot"
git commit -a -m "chore(bump): [CI] [DEV] bump ${{ env.COMPONENT }} package ${{ matrix.package }} to $VERSION"
git push origin master
static-analysis:
name: Static Analysis
runs-on:
#- self-hosted
#- large
- ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Create SBOM
uses: anchore/sbom-action@v0
with:
upload-artifact-retention: 1
format: cyclonedx-json
output-file: package-sbom.cyclonedx.json
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_S3_SBOMS_ROLE_ARN }}
aws-region: ${{ env.AWS_S3_REGION }}
- name: Copy SBOM to S3
run: |
aws s3 cp package-sbom.cyclonedx.json s3://repos-sboms/${{ github.event.repository.name }}/package-sbom.cyclonedx.json