11name : Publish Docker Images 🐋 📦
2+ concurrency : ci-${{ github.ref }}
23on :
34 push :
45 branches :
56 - main
67jobs :
78 version :
9+ name : Bump Version 🏷️
810 runs-on : ubuntu-latest
911 outputs :
1012 version : ${{ steps.create_tag.outputs.new_tag }}
2325 DRY_RUN : true
2426
2527 build :
28+ name : Build Docker Image 🐳
2629 needs : version
2730 runs-on : ubuntu-latest
2831 permissions :
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
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