-
-
Notifications
You must be signed in to change notification settings - Fork 22
169 lines (148 loc) · 4.67 KB
/
docker-publish.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
name: Docker Publish
on:
workflow_dispatch:
push:
paths:
- "generate-dockerfiles.sh"
- "generate-docker-compose.yml"
- "requirements.txt"
- "Dockerfile.j2"
- "docker-compose.yml.j2"
schedule:
- cron: "0 3 * * 6"
jobs:
generate-dockerfiles:
name: Generate Dockerfiles
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Generate python
uses: actions/setup-python@v5
with:
cache: "pip"
- run: pip3 install -r requirements.txt
- name: Generate Dockerfile with generate-dockerfiles.sh
run: ./generate-dockerfiles.sh
- name: Upload a Build Artifact
uses: actions/[email protected]
with:
# Artifact name
name: Dockerfiles
# A file, directory or wildcard pattern that describes what to upload
path: dockerfiles
- name: Push commit
uses: EndBug/add-and-commit@v9
with:
message: "Generate Dockerfiles"
add: "dockerfiles/Dockerfile*"
- id: set-matrix
run: |
shortnamearray=$(cat shortnamearray.json)
echo "${shortnamearray}"
echo -n "matrix=${shortnamearray}" >> $GITHUB_OUTPUT
generate-docker-compose:
name: Generate docker-compose.yml files
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v5
with:
cache: "pip"
- run: pip3 install -r requirements.txt
- name: Generate docker-compose.yml files with generate-docker-compose.sh
run: ./generate-docker-compose.sh
- name: Push commit
uses: EndBug/add-and-commit@v9
with:
message: "Generate docker-compose.yml files"
add: "docker-compose/docker-compose*"
docker-publish:
name: Publish Docker Images
needs: generate-dockerfiles
runs-on: ubuntu-latest
continue-on-error: true
strategy:
matrix: ${{ fromJSON(needs.generate-dockerfiles.outputs.matrix) }}
steps:
- name: Random Wait
uses: m3y/random-wait-action@v1
with:
max-wait-time: 30
- name: Checkout
uses: actions/checkout@v4
- name: Remove old Dockerfiles
run: rm -rf dockerfiles
- name: Download a Build Artifact
uses: actions/[email protected]
with:
# Artifact name
name: Dockerfiles
# Destination path
path: dockerfiles
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Login to DockerHub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/[email protected]
with:
context: .
file: dockerfiles/Dockerfile.${{ matrix.shortname }}
platforms: linux/amd64
push: true
build-args: |
SHORTNAME=${{ matrix.shortname }}
tags: |
gameservermanagers/gameserver:${{ matrix.shortname }}
ghcr.io/gameservermanagers/gameserver:${{ matrix.shortname }}
package-cleanup:
name: Cleanup Old GitHub Packages
runs-on: ubuntu-latest
steps:
- name: Delete Package Versions
uses: actions/delete-package-versions@v5
with:
package-name: gameserver
package-type: container
min-versions-to-keep: 1
delete-only-untagged-versions: true
package-cleanup-2:
name: Cleanup Old GitHub Packages 2
needs: package-cleanup
runs-on: ubuntu-latest
steps:
- name: Delete Package Versions
uses: actions/delete-package-versions@v5
with:
package-name: gameserver
package-type: container
min-versions-to-keep: 1
delete-only-untagged-versions: true
package-cleanup-3:
name: Cleanup Old GitHub Packages 3
needs: package-cleanup-2
runs-on: ubuntu-latest
steps:
- name: Delete Package Versions
uses: actions/delete-package-versions@v5
with:
package-name: gameserver
package-type: container
min-versions-to-keep: 1
delete-only-untagged-versions: true