-
Notifications
You must be signed in to change notification settings - Fork 2
262 lines (244 loc) · 10.3 KB
/
release.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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
name: Release
on:
workflow_dispatch:
push:
branches:
- master
paths:
- 'apps/**'
- 'base/**'
- 'mod/**'
- 'nightly/**'
env:
GOSS_SLEEP: 30
MOBY: "moby/buildkit:latest"
PLATFORM: "linux/amd64,linux/arm64"
DOCKER_CLI_EXPERIMENTAL: enabled
LICENSE: "GPL-3.0 DockServer.io"
SOURCE: "https://github.com/dockserver/container"
CODE_OWNED: "base image LSIO, changes dockserver.io"
CACHE: "gha"
jobs:
changes:
name: Get changes
runs-on: ubuntu-latest
#runs-on: self-hosted
outputs:
matrix: "{\"container\": ${{ steps.reduce.outputs.containers }} }"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
repository: ${{ github.repository }}
token: ${{ secrets.CR_PAT }}
fetch-depth: 0
- uses: dorny/paths-filter@v3
id: filter
with:
list-files: json
filters: |
changed:
- 'apps/**'
- 'base/**'
- 'mod/**'
- 'nightly/**'
- run: echo '${{ toJson(steps.filter.outputs) }}' > changes.json
- id: reduce
run: |
CONTAINERS=$(jq --raw-output '.changed_files | fromjson | .[] |= sub("(?<filepath>(?<first_directory>(?<root1>[/]?)[^/]+/)(?<second_directory>(?<root2>[/]?)[^/]+)(?<extra_paths>.+))"; "\(.second_directory)") | unique' changes.json)
echo ::set-output name=containers::${CONTAINERS}
build:
name: Build Docker
runs-on: ubuntu-latest
##runs-on: self-hosted
continue-on-error: true
permissions:
contents: read
packages: write
id-token: write
actions: write
checks: write
needs:
- changes
strategy:
max-parallel: 16
fail-fast: false
matrix: ${{ fromJson(needs.changes.outputs.matrix) }}
if: "!contains(github.event.head_commit.message, '[ci-skip]')"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
repository: ${{ github.repository }}
token: ${{ secrets.CR_PAT }}
fetch-depth: 0
- name: Prepare
id: prep
run: |
if test -f "./apps/${{ matrix.container }}/Dockerfile"; then
CATEGORY="apps"
elif test -f "./mod/${{ matrix.container }}/Dockerfile"; then
CATEGORY="mod"
elif test -f "./nightly/${{ matrix.container }}/Dockerfile"; then
CATEGORY="nightly"
else
CATEGORY="base"
fi
echo "category=${CATEGORY}" >> $GITHUB_OUTPUT
VERSION=$(jq -r '.newversion' < ./${CATEGORY}/${{ matrix.container }}/release.json)
echo "version=${VERSION}" >> $GITHUB_OUTPUT
DESCRIPTION=$(jq -r '.description' < ./${CATEGORY}/${{ matrix.container }}/release.json)
echo "description=${DESCRIPTION}" >> $GITHUB_OUTPUT
echo "platform=${PLATFORM}" >> $GITHUB_OUTPUT
echo "shashort=$(echo ${GITHUB_SHA} | cut -c1-8)" >> $GITHUB_OUTPUT
CREATED="$(date +%Y-%m-%d)"
echo "created=${CREATED}" >> $GITHUB_OUTPUT
echo "platformout=${{ env.PLATFORM }}" >> $GITHUB_OUTPUT
echo "linc=${{ env.LICENSE }}" >> $GITHUB_OUTPUT
echo "owndocker=${{ env.CODE_OWNED }}" >> $GITHUB_OUTPUT
if [ "${{ github.event_name }}" == "pull_request" ]; then
echo "push=false" >> $GITHUB_OUTPUT
else
echo "push=true" >> $GITHUB_OUTPUT
fi
- name: Set up QEMU
if: ${{ steps.prep.outputs.version != '' }}
uses: docker/[email protected]
with:
platforms: ${{ steps.prep.outputs.platformout }}
- name: Login in Registry || major
if: ${{ steps.prep.outputs.version != '' }}
uses: docker/[email protected]
with:
registry: ${{ secrets.DOCKER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.CR_PAT }}
- name: Login in Registry || mirror
uses: docker/[email protected]
if: ${{ steps.prep.outputs.version != '' }}
with:
registry: ${{ secrets.OWN_REGISTRY }}
username: ${{ secrets.QR_LOGIN }}
password: ${{ secrets.CR_QUAI }}
- name: Set up Docker Buildx
if: ${{ steps.prep.outputs.version != '' }}
id: buildx
uses: docker/[email protected]
with:
install: true
buildkitd-flags: --debug
version: latest
driver: docker-container
driver-opts: |
image=${{ env.MOBY }}
network=host
- name: Extract Docker metadata
if: ${{ steps.prep.outputs.version != '' }}
id: meta
uses: docker/metadata-action@8e1d5461f02b7886d3c1a774bfbd873650445aa2
with:
images: ${{ secrets.DOCKER_REGISTRY }}/${{ github.repository_owner }}/${{ matrix.container }}
- name: Build and Push Image
if: ${{ steps.prep.outputs.version != '' }}
id: build-and-push
uses: docker/[email protected]
with:
build-args: VERSION=${{ steps.prep.outputs.version }}
context: .
platforms: ${{ steps.prep.outputs.platformout }}
file: ./${{ steps.prep.outputs.category }}/${{ matrix.container }}/Dockerfile
push: ${{ steps.prep.outputs.push }}
tags: |
${{ secrets.DOCKER_REGISTRY }}/${{ github.repository_owner }}/${{ matrix.container }}:latest
${{ secrets.DOCKER_REGISTRY }}/${{ github.repository_owner }}/${{ matrix.container }}:${{ steps.prep.outputs.shashort }}
${{ secrets.DOCKER_REGISTRY }}/${{ github.repository_owner }}/${{ matrix.container }}:${{ steps.prep.outputs.created }}
${{ secrets.DOCKER_REGISTRY }}/${{ github.repository_owner }}/${{ matrix.container }}:${{ steps.prep.outputs.version }}
${{ secrets.DOCKER_REGISTRY }}/${{ github.repository_owner }}/${{ matrix.container }}:v${{ steps.prep.outputs.version }}
${{ secrets.OWN_REGISTRY }}/${{ github.repository_owner }}/${{ matrix.container }}:latest
${{ secrets.OWN_REGISTRY }}/${{ github.repository_owner }}/${{ matrix.container }}:${{ steps.prep.outputs.shashort }}
${{ secrets.OWN_REGISTRY }}/${{ github.repository_owner }}/${{ matrix.container }}:${{ steps.prep.outputs.created }}
${{ secrets.OWN_REGISTRY }}/${{ github.repository_owner }}/${{ matrix.container }}:${{ steps.prep.outputs.version }}
${{ secrets.OWN_REGISTRY }}/${{ github.repository_owner }}/${{ matrix.container }}:v${{ steps.prep.outputs.version }}
labels: |
maintainer=${{ github.repository_owner }}
org.opencontainers.image.title=${{ matrix.container }}
org.opencontainers.image.source=https://github.com/${{ github.repository }}
org.opencontainers.image.version=${{ steps.prep.outputs.version }}
org.opencontainers.image.maintainer=${{ github.repository_owner }}
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
org.opencontainers.image.authors=${{ github.repository_owner }}
org.opencontainers.image.vendor=${{ github.repository_owner }}
org.opencontainers.image.platform=${{ steps.prep.outputs.platformout }}
org.opencontainers.image.license=${{ steps.prep.outputs.linc }}
org.opencontainers.image.description=${{ steps.prep.outputs.description }}
org.opencontainers.image.owner=${{ steps.prep.outputs.owndocker }}
org.opencontainers.image.shaid=${{ steps.prep.outputs.shashort }}
- name: Image digest
if: ${{ steps.prep.outputs.version != '' }}
run: echo ${{ steps.docker_build.outputs.digest }}
- name: Send notification
if: ${{ steps.prep.outputs.version != '' }}
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_IMAGES }}
VERSION: ${{ steps.prep.outputs.version }}
SHA8: ${{ steps.prep.outputs.shashort }}
CATEGORY: ${{ steps.prep.outputs.category }}
DESCRIPTION: ${{ steps.prep.outputs.description }}
COLOR: 3066993
shell: bash
run: |
if [[ -f "./images/${{ matrix.container }}.png" ]]; then
cp -r "./images/${{ matrix.container }}.png" image.png
else
cp -r "./images/image.png" image.png
fi
export DOCKER_CLI_EXPERIMENTAL=enabled
json='{
"username": "Docker Image Update",
"avatar_url": "https://github.com/dockserver/dockserver/raw/master/wiki/overrides/img/profile.png",
"embeds": [
{
"author": {
"name": "'${{ github.repository_owner }}'"
},
"title": "'${{ matrix.container }}'",
"url": "https://github.com/orgs/'${{ github.repository_owner }}'/packages/container/package/'${{ matrix.container }}'",
"color": '${COLOR}',
"fields": [
{
"name": "Container Info",
"value": "We published a new container image '${{ matrix.container }}'"
},
{
"name": "Description of docker",
"value": "`'${DESCRIPTION}'`"
},
{
"name": "Version",
"value": "new Version public : `'${VERSION}'` with `'${SHA8}'`"
},
{
"name": "Docker Tags : '${{ secrets.DOCKER_REGISTRY }}'",
"value": "`'${{ secrets.DOCKER_REGISTRY }}'/'${{ github.repository_owner }}'/'${{ matrix.container }}':latest`\nor\n`'${{ secrets.DOCKER_REGISTRY }}'/'${{ github.repository_owner }}'/'${{ matrix.container }}':v'${VERSION:----}'`"
},
{
"name": "Docker Tags : Dockserver Registry",
"value": "`docker.dockserver.io/'${{ github.repository_owner }}'/'${{ matrix.container }}':latest`\nor\n`docker.dockserver.io/'${{ github.repository_owner }}'/'${{ matrix.container }}':v'${VERSION}'`"
},
{
"name": "Thanks!",
"value": "Thanks! to all Contributors"
}
],
"footer": {
"text": "Powered by GitHub Actions",
"icon_url": "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png"
},
"timestamp": "'$(date -u +'%FT%T.%3NZ')'",
"image": {
"url": "attachment://image.png"
}
}
]
}'
curl -fsSL --retry 5 -H "Content-Type: multipart/form-data" -F "[email protected]" -F "payload_json=${json}" "${DISCORD_WEBHOOK}" > /dev/null