Skip to content

Commit a2fe226

Browse files
build: ⚙️ Bump to Ubuntu 24, improve unit test coverage (#50)
#minor Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: JamesIves <[email protected]>
1 parent 9a1ef05 commit a2fe226

File tree

11 files changed

+293
-88
lines changed

11 files changed

+293
-88
lines changed

.github/dependabot.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,8 @@ updates:
44
directory: "/"
55
schedule:
66
interval: "weekly"
7+
8+
- package-ecosystem: "docker"
9+
directory: "/container"
10+
schedule:
11+
interval: "weekly"

.github/workflows/beta.yml

Lines changed: 95 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
name: Publish Beta Docker Images 🐋 📦
2+
concurrency: ci-${{ github.ref }}
23
on:
34
push:
45
branches:
56
- beta
67
jobs:
78
build:
9+
name: Build Beta Docker Image 🐳
810
runs-on: ubuntu-latest
911
permissions:
1012
packages: write
@@ -56,7 +58,7 @@ jobs:
5658
GAME=${GAME%-legacy}
5759
echo "GAME=$GAME" >> $GITHUB_ENV
5860
59-
- name: Replace fallback value in Dockerfile and entrypoint.sh
61+
- name: Replace fallback value in Dockerfile and entrypoint.sh 📝
6062
working-directory: ./container
6163
run: |
6264
sed -i "s/\${GAME:-valve}/\${GAME:-${{ env.GAME }}}/g" Dockerfile
@@ -66,6 +68,84 @@ jobs:
6668
if: contains(matrix.game, 'legacy')
6769
run: echo "FLAG=-beta steam_legacy" >> $GITHUB_ENV
6870

71+
- name: Build Docker Image 🐳
72+
uses: docker/build-push-action@v6
73+
env:
74+
GAME: ${{ env.GAME }}
75+
FLAG: ${{ env.FLAG }}
76+
VERSION: beta
77+
IMAGE: jives/hlds:${{ matrix.game }}-beta
78+
with:
79+
context: ./container
80+
push: false
81+
load: true
82+
tags: jives/hlds:${{ matrix.game }}-beta
83+
build-args: |
84+
GAME=${{ env.GAME }}
85+
FLAG=${{ env.FLAG }}
86+
IMAGE=jives/hlds:${{ matrix.game }}-beta
87+
VERSION=beta
88+
89+
- name: Get Docker Image ID 🆔
90+
id: get_image_id
91+
run: echo "image_id=$(docker images -q | head -n 1)" >> $GITHUB_ENV
92+
93+
- name: Add Custom Mod Content 📂
94+
run: |
95+
mkdir -p ./mods/decay
96+
touch ./mods/decay/plugin.ini
97+
98+
- name: Add Configuration 📂
99+
run: |
100+
mkdir -p ./config
101+
mkdir -p ./config/maps
102+
touch ./config/test.cfg
103+
touch ./config/maps/crazytank.bsp
104+
105+
- name: Run Docker Container 🐳
106+
run: |
107+
docker run -d -ti \
108+
--name hlds \
109+
-v "./config:/temp/config" \
110+
-v "./mods:/temp/mods" \
111+
-p 27015:27015/udp \
112+
-p 27015:27015 \
113+
-p 26900:26900/udp \
114+
-e GAME=${GAME} \
115+
${{ env.image_id }} \
116+
"+log on +rcon_password changeme +maxplayers 12"
117+
sleep 5
118+
119+
- name: Validate Directory Mappings 📂
120+
run: |
121+
# Check if plugin.ini exists in the decay directory
122+
if [ "$(docker exec hlds ls /opt/steam/hlds/decay | grep -c 'plugin.ini')" -eq 0 ]; then
123+
echo "plugin.ini file is missing in the decay directory!"
124+
exit 1
125+
fi
126+
127+
# Check if test.cfg exists in the game directory
128+
if [ "$(docker exec hlds ls /opt/steam/hlds/${{ env.GAME }} | grep -c 'test.cfg')" -eq 0 ]; then
129+
echo "test.cfg file is missing in the ${{ env.GAME }} directory!"
130+
exit 1
131+
fi
132+
133+
# Check if crazytank.bsp exists in the maps directory
134+
if [ "$(docker exec hlds ls /opt/steam/hlds/${{ env.GAME }}/maps | grep -c 'crazytank.bsp')" -eq 0 ]; then
135+
echo "crazytank.bsp file is missing in the maps directory!"
136+
exit 1
137+
fi
138+
139+
echo "Volume mappings work as expectected!"
140+
141+
- name: Validate Game Data Is Available 📂
142+
run: |
143+
GAME_NAME=$(echo "${{ env.GAME }}" | sed 's/-legacy//')
144+
if [ "$(docker exec hlds ls /opt/steam/hlds | grep -c "$GAME_NAME")" -eq 0 ]; then
145+
echo "$GAME_NAME directory is missing!"
146+
exit 1
147+
fi
148+
69149
- name: Build and Push Docker Image to DockerHub 🐳
70150
uses: docker/build-push-action@v6
71151
env:
@@ -83,23 +163,32 @@ jobs:
83163
IMAGE=jives/hlds:${{ matrix.game }}-beta
84164
VERSION=beta
85165
86-
- name: Set repo owner to lowercase
166+
- name: Set repo owner to lowercase 📝
87167
id: repo_owner
88-
run: echo "::set-output name=repo_owner::$(echo ${{ github.repository_owner }} | awk '{print tolower($0)}')"
168+
run: |
169+
REPO_OWNER=$(echo ${{ github.repository_owner }} | awk '{print tolower($0)}')
170+
echo "repo_owner=$REPO_OWNER" >> $GITHUB_ENV
89171
90172
- name: Build and Push Docker Image to GitHub Container Registry 🐳
91173
uses: docker/build-push-action@v6
92174
env:
93175
GAME: ${{ env.GAME }}
94176
FLAG: ${{ env.FLAG }}
95177
VERSION: beta
96-
IMAGE: ghcr.io/${{ steps.repo_owner.outputs.repo_owner }}/hlds:${{ matrix.game }}-beta
178+
IMAGE: ghcr.io/${{ env.repo_owner }}/hlds:${{ matrix.game }}-beta
97179
with:
98180
context: ./container
99181
push: true
100-
tags: ghcr.io/${{ steps.repo_owner.outputs.repo_owner }}/hlds:${{ matrix.game }}-beta
182+
tags: ghcr.io/${{ env.repo_owner }}/hlds:${{ matrix.game }}-beta
101183
build-args: |
102184
GAME=${{ env.GAME }}
103185
FLAG=${{ env.FLAG }}
104186
VERSION=beta
105-
IMAGE=ghcr.io/${{ steps.repo_owner.outputs.repo_owner }}/hlds:${{ matrix.game }}-beta
187+
IMAGE=ghcr.io/${{ env.repo_owner }}/hlds:${{ matrix.game }}-beta
188+
189+
- name: Cleanup 🧹
190+
if: always()
191+
run: |
192+
docker stop hlds
193+
docker rm hlds
194+
docker system prune --all --force

.github/workflows/publish.yml

Lines changed: 93 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
name: Publish Docker Images 🐋 📦
2+
concurrency: ci-${{ github.ref }}
23
on:
34
push:
45
branches:
56
- main
67
jobs:
78
version:
9+
name: Bump Version 🏷️
810
runs-on: ubuntu-latest
911
outputs:
1012
version: ${{ steps.create_tag.outputs.new_tag }}
@@ -23,6 +25,7 @@ jobs:
2325
DRY_RUN: true
2426

2527
build:
28+
name: Build Docker Image 🐳
2629
needs: version
2730
runs-on: ubuntu-latest
2831
permissions:
@@ -75,7 +78,7 @@ jobs:
7578
GAME=${GAME%-legacy}
7679
echo "GAME=$GAME" >> $GITHUB_ENV
7780
78-
- name: Replace fallback value in Dockerfile and entrypoint.sh
81+
- name: Replace fallback value in Dockerfile and entrypoint.sh 📝
7982
working-directory: ./container
8083
run: |
8184
sed -i "s/\${GAME:-valve}/\${GAME:-${{ env.GAME }}}/g" Dockerfile
@@ -85,6 +88,86 @@ jobs:
8588
if: contains(matrix.game, 'legacy')
8689
run: echo "FLAG=-beta steam_legacy" >> $GITHUB_ENV
8790

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+
88171
- name: Build and Push Docker Image to DockerHub 🐳
89172
uses: docker/build-push-action@v6
90173
env:
@@ -104,30 +187,33 @@ jobs:
104187
VERSION=${{ needs.version.outputs.version }}
105188
IMAGE=jives/hlds:${{ matrix.game }}-${{ needs.version.outputs.version }}
106189
107-
- name: Set repo owner to lowercase
190+
- name: Set repo owner to lowercase 📝
108191
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
110195
111196
- name: Build and Push Docker Image to GitHub Container Registry 🐳
112197
uses: docker/build-push-action@v6
113198
env:
114199
GAME: ${{ matrix.game }}
115200
FLAG: ${{ env.FLAG }}
116201
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 }}
118203
with:
119204
context: ./container
120205
push: true
121206
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 }}
124209
build-args: |
125210
GAME=${{ env.GAME }}
126211
FLAG=${{ env.FLAG }}
127212
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 }}
129214
130215
publish:
216+
name: Publish GitHub Release 🚀
131217
needs: build
132218
runs-on: ubuntu-latest
133219
permissions:

0 commit comments

Comments
 (0)