1
1
name : Publish Docker Images 🐋 📦
2
+ concurrency : ci-${{ github.ref }}
2
3
on :
3
4
push :
4
5
branches :
5
6
- main
6
7
jobs :
7
8
version :
9
+ name : Bump Version 🏷️
8
10
runs-on : ubuntu-latest
9
11
outputs :
10
12
version : ${{ steps.create_tag.outputs.new_tag }}
23
25
DRY_RUN : true
24
26
25
27
build :
28
+ name : Build Docker Image 🐳
26
29
needs : version
27
30
runs-on : ubuntu-latest
28
31
permissions :
75
78
GAME=${GAME%-legacy}
76
79
echo "GAME=$GAME" >> $GITHUB_ENV
77
80
78
- - name : Replace fallback value in Dockerfile and entrypoint.sh
81
+ - name : Replace fallback value in Dockerfile and entrypoint.sh 📝
79
82
working-directory : ./container
80
83
run : |
81
84
sed -i "s/\${GAME:-valve}/\${GAME:-${{ env.GAME }}}/g" Dockerfile
85
88
if : contains(matrix.game, 'legacy')
86
89
run : echo "FLAG=-beta steam_legacy" >> $GITHUB_ENV
87
90
91
+ - name : Build Docker Image 🐳
92
+ uses : docker/build-push-action@v6
93
+ env :
94
+ GAME : ${{ env.GAME }}
95
+ FLAG : ${{ env.FLAG }}
96
+ VERSION : ${{ needs.version.outputs.version }}
97
+ IMAGE : jives/hlds:${{ matrix.game }}-${{ needs.version.outputs.version }}
98
+ with :
99
+ context : ./container
100
+ push : false
101
+ load : true
102
+ tags : |
103
+ jives/hlds:${{ matrix.game }}
104
+ jives/hlds:${{ matrix.game }}-${{ needs.version.outputs.version }}
105
+ build-args : |
106
+ GAME=${{ env.GAME}}
107
+ FLAG=${{ env.FLAG }}
108
+ VERSION=${{ needs.version.outputs.version }}
109
+ IMAGE=jives/hlds:${{ matrix.game }}-${{ needs.version.outputs.version }}
110
+
111
+ - name : Get Docker Image ID 🆔
112
+ id : get_image_id
113
+ run : echo "image_id=$(docker images -q | head -n 1)" >> $GITHUB_ENV
114
+
115
+ - name : Add Custom Mod Content 📂
116
+ run : |
117
+ mkdir -p ./mods/decay
118
+ touch ./mods/decay/plugin.ini
119
+
120
+ - name : Add Configuration 📂
121
+ run : |
122
+ mkdir -p ./config
123
+ mkdir -p ./config/maps
124
+ touch ./config/test.cfg
125
+ touch ./config/maps/crazytank.bsp
126
+
127
+ - name : Run Docker Container 🐳
128
+ run : |
129
+ docker run -d -ti \
130
+ --name hlds \
131
+ -v "./config:/temp/config" \
132
+ -v "./mods:/temp/mods" \
133
+ -p 27015:27015/udp \
134
+ -p 27015:27015 \
135
+ -p 26900:26900/udp \
136
+ -e GAME=${GAME} \
137
+ ${{ env.image_id }} \
138
+ "+log on +rcon_password changeme +maxplayers 12"
139
+ sleep 5
140
+
141
+ - name : Validate Directory Mappings 📂
142
+ run : |
143
+ # Check if plugin.ini exists in the decay directory
144
+ if [ "$(docker exec hlds ls /opt/steam/hlds/decay | grep -c 'plugin.ini')" -eq 0 ]; then
145
+ echo "plugin.ini file is missing in the decay directory!"
146
+ exit 1
147
+ fi
148
+
149
+ # Check if test.cfg exists in the game directory
150
+ if [ "$(docker exec hlds ls /opt/steam/hlds/${{ env.GAME }} | grep -c 'test.cfg')" -eq 0 ]; then
151
+ echo "test.cfg file is missing in the ${{ env.GAME }} directory!"
152
+ exit 1
153
+ fi
154
+
155
+ # Check if crazytank.bsp exists in the maps directory
156
+ if [ "$(docker exec hlds ls /opt/steam/hlds/${{ env.GAME }}/maps | grep -c 'crazytank.bsp')" -eq 0 ]; then
157
+ echo "crazytank.bsp file is missing in the maps directory!"
158
+ exit 1
159
+ fi
160
+
161
+ echo "Volume mappings work as expectected!"
162
+
163
+ - name : Validate Game Data Is Available 📂
164
+ run : |
165
+ GAME_NAME=$(echo "${{ env.GAME }}" | sed 's/-legacy//')
166
+ if [ "$(docker exec hlds ls /opt/steam/hlds | grep -c "$GAME_NAME")" -eq 0 ]; then
167
+ echo "$GAME_NAME directory is missing!"
168
+ exit 1
169
+ fi
170
+
88
171
- name : Build and Push Docker Image to DockerHub 🐳
89
172
uses : docker/build-push-action@v6
90
173
env :
@@ -104,30 +187,33 @@ jobs:
104
187
VERSION=${{ needs.version.outputs.version }}
105
188
IMAGE=jives/hlds:${{ matrix.game }}-${{ needs.version.outputs.version }}
106
189
107
- - name : Set repo owner to lowercase
190
+ - name : Set repo owner to lowercase 📝
108
191
id : repo_owner
109
- run : echo "::set-output name=repo_owner::$(echo ${{ github.repository_owner }} | awk '{print tolower($0)}')"
192
+ run : |
193
+ REPO_OWNER=$(echo ${{ github.repository_owner }} | awk '{print tolower($0)}')
194
+ echo "repo_owner=$REPO_OWNER" >> $GITHUB_ENV
110
195
111
196
- name : Build and Push Docker Image to GitHub Container Registry 🐳
112
197
uses : docker/build-push-action@v6
113
198
env :
114
199
GAME : ${{ matrix.game }}
115
200
FLAG : ${{ env.FLAG }}
116
201
VERSION : ${{ needs.version.outputs.version }}
117
- IMAGE : ghcr.io/${{ steps.repo_owner.outputs .repo_owner }}/hlds:${{ matrix.game }}-${{ needs.version.outputs.version }}
202
+ IMAGE : ghcr.io/${{ env .repo_owner }}/hlds:${{ matrix.game }}-${{ needs.version.outputs.version }}
118
203
with :
119
204
context : ./container
120
205
push : true
121
206
tags : |
122
- ghcr.io/${{ steps.repo_owner.outputs .repo_owner }}/hlds:${{ matrix.game }}
123
- ghcr.io/${{ steps.repo_owner.outputs .repo_owner }}/hlds:${{ matrix.game }}-${{ needs.version.outputs.version }}
207
+ ghcr.io/${{ env .repo_owner }}/hlds:${{ matrix.game }}
208
+ ghcr.io/${{ env .repo_owner }}/hlds:${{ matrix.game }}-${{ needs.version.outputs.version }}
124
209
build-args : |
125
210
GAME=${{ env.GAME }}
126
211
FLAG=${{ env.FLAG }}
127
212
VERSION=${{ needs.version.outputs.version }}
128
- IMAGE=ghcr.io/${{ steps.repo_owner.outputs .repo_owner }}/hlds:${{ matrix.game }}-${{ needs.version.outputs.version }}
213
+ IMAGE=ghcr.io/${{ env .repo_owner }}/hlds:${{ matrix.game }}-${{ needs.version.outputs.version }}
129
214
130
215
publish :
216
+ name : Publish GitHub Release 🚀
131
217
needs : build
132
218
runs-on : ubuntu-latest
133
219
permissions :
0 commit comments