forked from discordeno/discordeno
-
Notifications
You must be signed in to change notification settings - Fork 0
219 lines (211 loc) · 7.99 KB
/
docker-app-rest-passthrough.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
219
name: Docker App - Rest Passthrough
on:
push:
branches:
- 'main'
paths:
- '.github/workflows/docker-app-rest-passthrough.yml'
- 'docker-apps/rest-passthrough/**'
pull_request:
merge_group:
schedule:
- cron: '0 0 * * *'
jobs:
# Removing this for now until I can confirm a couple things and ensure it works fully
# - Matt H
# run-release:
# name: Run release script
# runs-on: ubuntu-latest
# if: ${{ github.ref == 'refs/heads/main' && github.event_name == 'push' }}
# steps:
# - name: Checkout repository
# uses: actions/checkout@v4
# - name: Git config
# run: |
# git config user.name github-actions
# git config user.email github-actions@github.com
# - name: Run release script
# run: |
# yarn install --immutable
# yarn release
# git push && git push --tags
app-version:
name: Get app version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.package-version.outputs.current-version }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: get-npm-version
id: package-version
uses: martinbeentjes/npm-get-version-action@v1.3.1
with:
path: docker-apps/rest-passthrough
build:
name: Build docker image
runs-on: ubuntu-latest
needs: app-version
steps:
- uses: actions/checkout@v4
- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-single-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-single-buildx
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v6
with:
push: false
tags: 'discordeno/app-rest-passthrough:latest, discordeno/app-rest-passthrough:v${{ needs.app-version.outputs.version }}'
context: docker-apps/rest-passthrough
target: runner
outputs: type=docker,dest=/tmp/rest-passthrough-image.tar
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
- # Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: rest-passthrough-image
path: /tmp/rest-passthrough-image.tar
image-scan:
name: Image scan
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: rest-passthrough-image
path: /tmp
- name: Load Docker image
run: docker load --input /tmp/rest-passthrough-image.tar
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
if: ${{ github.event_name == 'schedule' || github.event_name == 'push' }}
with:
image-ref: 'discordeno/app-rest-passthrough:latest'
format: 'table'
exit-code: '0'
ignore-unfixed: true
vuln-type: 'os,library'
severity: 'UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL'
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
if: ${{ github.event_name == 'schedule' || github.event_name == 'push' }}
with:
image-ref: 'discordeno/app-rest-passthrough:latest'
exit-code: '0'
vuln-type: 'os,library'
severity: 'UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL'
format: 'sarif'
output: 'trivy-results.sarif'
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v3
if: ${{ github.event_name == 'schedule' || github.event_name == 'push' }}
with:
sarif_file: 'trivy-results.sarif'
- name: Run Snyk to check Docker image for vulnerabilities
if: ${{ github.event_name == 'schedule' || github.event_name == 'push' }}
continue-on-error: true
uses: snyk/actions/docker@master
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
image: 'discordeno/app-rest-passthrough:latest'
args: --file=docker-apps/rest-passthrough/Dockerfile
# Snyk will use a security-severify of "null" when the CVE didn't get an assigned score
- name: Replace security-severity null for non assigned CVE scores
if: ${{ github.event_name == 'schedule' || github.event_name == 'push' }}
run: |
sed -i 's/"security-severity": "null"/"security-severity": "0"/g' snyk.sarif
sed -i 's/"cvssv3_baseScore": null/"cvssv3_baseScore": 0/g' snyk.sarif
- name: Upload snyk scan results to GitHub Security tab
if: ${{ github.event_name == 'schedule' || github.event_name == 'push' }}
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: snyk.sarif
build-all-arch:
name: Build image for all architectures
needs: [build, app-version]
if: ${{ github.event_name != 'schedule' }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-single-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-single-buildx
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker image
uses: docker/build-push-action@v6
with:
context: docker-apps/rest-passthrough
push: false
tags: 'discordeno/app-rest-passthrough:latest, discordeno/app-rest-passthrough:v${{ needs.app-version.outputs.version }}'
# linux/s390x stuck at yarn install, remove it for now
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/ppc64le
target: runner
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
- # Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
publish:
name: Publish image
# needs: [run-release, build-all-arch, app-version]
needs: [build-all-arch, app-version]
if: ${{ github.ref == 'refs/heads/main' && github.event_name == 'push' }}
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: docker-apps/rest-passthrough
push: true
tags: 'ghcr.io/discordeno/app-rest-passthrough:latest, ghcr.io/discordeno/app-rest-passthrough:v${{ needs.app-version.outputs.version }}'
# linux/s390x stuck at yarn install, remove it for now
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/ppc64le
target: runner