Skip to content

Commit

Permalink
build: ⚙️ Bump to Ubuntu 24, improve unit test coverage (#50)
Browse files Browse the repository at this point in the history
#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]>
  • Loading branch information
3 people authored Oct 3, 2024
1 parent 9a1ef05 commit a2fe226
Show file tree
Hide file tree
Showing 11 changed files with 293 additions and 88 deletions.
5 changes: 5 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@ updates:
directory: "/"
schedule:
interval: "weekly"

- package-ecosystem: "docker"
directory: "/container"
schedule:
interval: "weekly"
101 changes: 95 additions & 6 deletions .github/workflows/beta.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
name: Publish Beta Docker Images 🐋 📦
concurrency: ci-${{ github.ref }}
on:
push:
branches:
- beta
jobs:
build:
name: Build Beta Docker Image 🐳
runs-on: ubuntu-latest
permissions:
packages: write
Expand Down Expand Up @@ -56,7 +58,7 @@ jobs:
GAME=${GAME%-legacy}
echo "GAME=$GAME" >> $GITHUB_ENV
- name: Replace fallback value in Dockerfile and entrypoint.sh
- name: Replace fallback value in Dockerfile and entrypoint.sh 📝
working-directory: ./container
run: |
sed -i "s/\${GAME:-valve}/\${GAME:-${{ env.GAME }}}/g" Dockerfile
Expand All @@ -66,6 +68,84 @@ jobs:
if: contains(matrix.game, 'legacy')
run: echo "FLAG=-beta steam_legacy" >> $GITHUB_ENV

- name: Build Docker Image 🐳
uses: docker/build-push-action@v6
env:
GAME: ${{ env.GAME }}
FLAG: ${{ env.FLAG }}
VERSION: beta
IMAGE: jives/hlds:${{ matrix.game }}-beta
with:
context: ./container
push: false
load: true
tags: jives/hlds:${{ matrix.game }}-beta
build-args: |
GAME=${{ env.GAME }}
FLAG=${{ env.FLAG }}
IMAGE=jives/hlds:${{ matrix.game }}-beta
VERSION=beta
- name: Get Docker Image ID 🆔
id: get_image_id
run: echo "image_id=$(docker images -q | head -n 1)" >> $GITHUB_ENV

- name: Add Custom Mod Content 📂
run: |
mkdir -p ./mods/decay
touch ./mods/decay/plugin.ini
- name: Add Configuration 📂
run: |
mkdir -p ./config
mkdir -p ./config/maps
touch ./config/test.cfg
touch ./config/maps/crazytank.bsp
- name: Run Docker Container 🐳
run: |
docker run -d -ti \
--name hlds \
-v "./config:/temp/config" \
-v "./mods:/temp/mods" \
-p 27015:27015/udp \
-p 27015:27015 \
-p 26900:26900/udp \
-e GAME=${GAME} \
${{ env.image_id }} \
"+log on +rcon_password changeme +maxplayers 12"
sleep 5
- name: Validate Directory Mappings 📂
run: |
# Check if plugin.ini exists in the decay directory
if [ "$(docker exec hlds ls /opt/steam/hlds/decay | grep -c 'plugin.ini')" -eq 0 ]; then
echo "plugin.ini file is missing in the decay directory!"
exit 1
fi
# Check if test.cfg exists in the game directory
if [ "$(docker exec hlds ls /opt/steam/hlds/${{ env.GAME }} | grep -c 'test.cfg')" -eq 0 ]; then
echo "test.cfg file is missing in the ${{ env.GAME }} directory!"
exit 1
fi
# Check if crazytank.bsp exists in the maps directory
if [ "$(docker exec hlds ls /opt/steam/hlds/${{ env.GAME }}/maps | grep -c 'crazytank.bsp')" -eq 0 ]; then
echo "crazytank.bsp file is missing in the maps directory!"
exit 1
fi
echo "Volume mappings work as expectected!"
- name: Validate Game Data Is Available 📂
run: |
GAME_NAME=$(echo "${{ env.GAME }}" | sed 's/-legacy//')
if [ "$(docker exec hlds ls /opt/steam/hlds | grep -c "$GAME_NAME")" -eq 0 ]; then
echo "$GAME_NAME directory is missing!"
exit 1
fi
- name: Build and Push Docker Image to DockerHub 🐳
uses: docker/build-push-action@v6
env:
Expand All @@ -83,23 +163,32 @@ jobs:
IMAGE=jives/hlds:${{ matrix.game }}-beta
VERSION=beta
- name: Set repo owner to lowercase
- name: Set repo owner to lowercase 📝
id: repo_owner
run: echo "::set-output name=repo_owner::$(echo ${{ github.repository_owner }} | awk '{print tolower($0)}')"
run: |
REPO_OWNER=$(echo ${{ github.repository_owner }} | awk '{print tolower($0)}')
echo "repo_owner=$REPO_OWNER" >> $GITHUB_ENV
- name: Build and Push Docker Image to GitHub Container Registry 🐳
uses: docker/build-push-action@v6
env:
GAME: ${{ env.GAME }}
FLAG: ${{ env.FLAG }}
VERSION: beta
IMAGE: ghcr.io/${{ steps.repo_owner.outputs.repo_owner }}/hlds:${{ matrix.game }}-beta
IMAGE: ghcr.io/${{ env.repo_owner }}/hlds:${{ matrix.game }}-beta
with:
context: ./container
push: true
tags: ghcr.io/${{ steps.repo_owner.outputs.repo_owner }}/hlds:${{ matrix.game }}-beta
tags: ghcr.io/${{ env.repo_owner }}/hlds:${{ matrix.game }}-beta
build-args: |
GAME=${{ env.GAME }}
FLAG=${{ env.FLAG }}
VERSION=beta
IMAGE=ghcr.io/${{ steps.repo_owner.outputs.repo_owner }}/hlds:${{ matrix.game }}-beta
IMAGE=ghcr.io/${{ env.repo_owner }}/hlds:${{ matrix.game }}-beta
- name: Cleanup 🧹
if: always()
run: |
docker stop hlds
docker rm hlds
docker system prune --all --force
100 changes: 93 additions & 7 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
name: Publish Docker Images 🐋 📦
concurrency: ci-${{ github.ref }}
on:
push:
branches:
- main
jobs:
version:
name: Bump Version 🏷️
runs-on: ubuntu-latest
outputs:
version: ${{ steps.create_tag.outputs.new_tag }}
Expand All @@ -23,6 +25,7 @@ jobs:
DRY_RUN: true

build:
name: Build Docker Image 🐳
needs: version
runs-on: ubuntu-latest
permissions:
Expand Down Expand Up @@ -75,7 +78,7 @@ jobs:
GAME=${GAME%-legacy}
echo "GAME=$GAME" >> $GITHUB_ENV
- name: Replace fallback value in Dockerfile and entrypoint.sh
- name: Replace fallback value in Dockerfile and entrypoint.sh 📝
working-directory: ./container
run: |
sed -i "s/\${GAME:-valve}/\${GAME:-${{ env.GAME }}}/g" Dockerfile
Expand All @@ -85,6 +88,86 @@ jobs:
if: contains(matrix.game, 'legacy')
run: echo "FLAG=-beta steam_legacy" >> $GITHUB_ENV

- name: Build Docker Image 🐳
uses: docker/build-push-action@v6
env:
GAME: ${{ env.GAME }}
FLAG: ${{ env.FLAG }}
VERSION: ${{ needs.version.outputs.version }}
IMAGE: jives/hlds:${{ matrix.game }}-${{ needs.version.outputs.version }}
with:
context: ./container
push: false
load: true
tags: |
jives/hlds:${{ matrix.game }}
jives/hlds:${{ matrix.game }}-${{ needs.version.outputs.version }}
build-args: |
GAME=${{ env.GAME}}
FLAG=${{ env.FLAG }}
VERSION=${{ needs.version.outputs.version }}
IMAGE=jives/hlds:${{ matrix.game }}-${{ needs.version.outputs.version }}
- name: Get Docker Image ID 🆔
id: get_image_id
run: echo "image_id=$(docker images -q | head -n 1)" >> $GITHUB_ENV

- name: Add Custom Mod Content 📂
run: |
mkdir -p ./mods/decay
touch ./mods/decay/plugin.ini
- name: Add Configuration 📂
run: |
mkdir -p ./config
mkdir -p ./config/maps
touch ./config/test.cfg
touch ./config/maps/crazytank.bsp
- name: Run Docker Container 🐳
run: |
docker run -d -ti \
--name hlds \
-v "./config:/temp/config" \
-v "./mods:/temp/mods" \
-p 27015:27015/udp \
-p 27015:27015 \
-p 26900:26900/udp \
-e GAME=${GAME} \
${{ env.image_id }} \
"+log on +rcon_password changeme +maxplayers 12"
sleep 5
- name: Validate Directory Mappings 📂
run: |
# Check if plugin.ini exists in the decay directory
if [ "$(docker exec hlds ls /opt/steam/hlds/decay | grep -c 'plugin.ini')" -eq 0 ]; then
echo "plugin.ini file is missing in the decay directory!"
exit 1
fi
# Check if test.cfg exists in the game directory
if [ "$(docker exec hlds ls /opt/steam/hlds/${{ env.GAME }} | grep -c 'test.cfg')" -eq 0 ]; then
echo "test.cfg file is missing in the ${{ env.GAME }} directory!"
exit 1
fi
# Check if crazytank.bsp exists in the maps directory
if [ "$(docker exec hlds ls /opt/steam/hlds/${{ env.GAME }}/maps | grep -c 'crazytank.bsp')" -eq 0 ]; then
echo "crazytank.bsp file is missing in the maps directory!"
exit 1
fi
echo "Volume mappings work as expectected!"
- name: Validate Game Data Is Available 📂
run: |
GAME_NAME=$(echo "${{ env.GAME }}" | sed 's/-legacy//')
if [ "$(docker exec hlds ls /opt/steam/hlds | grep -c "$GAME_NAME")" -eq 0 ]; then
echo "$GAME_NAME directory is missing!"
exit 1
fi
- name: Build and Push Docker Image to DockerHub 🐳
uses: docker/build-push-action@v6
env:
Expand All @@ -104,30 +187,33 @@ jobs:
VERSION=${{ needs.version.outputs.version }}
IMAGE=jives/hlds:${{ matrix.game }}-${{ needs.version.outputs.version }}
- name: Set repo owner to lowercase
- name: Set repo owner to lowercase 📝
id: repo_owner
run: echo "::set-output name=repo_owner::$(echo ${{ github.repository_owner }} | awk '{print tolower($0)}')"
run: |
REPO_OWNER=$(echo ${{ github.repository_owner }} | awk '{print tolower($0)}')
echo "repo_owner=$REPO_OWNER" >> $GITHUB_ENV
- name: Build and Push Docker Image to GitHub Container Registry 🐳
uses: docker/build-push-action@v6
env:
GAME: ${{ matrix.game }}
FLAG: ${{ env.FLAG }}
VERSION: ${{ needs.version.outputs.version }}
IMAGE: ghcr.io/${{ steps.repo_owner.outputs.repo_owner }}/hlds:${{ matrix.game }}-${{ needs.version.outputs.version }}
IMAGE: ghcr.io/${{ env.repo_owner }}/hlds:${{ matrix.game }}-${{ needs.version.outputs.version }}
with:
context: ./container
push: true
tags: |
ghcr.io/${{ steps.repo_owner.outputs.repo_owner }}/hlds:${{ matrix.game }}
ghcr.io/${{ steps.repo_owner.outputs.repo_owner }}/hlds:${{ matrix.game }}-${{ needs.version.outputs.version }}
ghcr.io/${{ env.repo_owner }}/hlds:${{ matrix.game }}
ghcr.io/${{ env.repo_owner }}/hlds:${{ matrix.game }}-${{ needs.version.outputs.version }}
build-args: |
GAME=${{ env.GAME }}
FLAG=${{ env.FLAG }}
VERSION=${{ needs.version.outputs.version }}
IMAGE=ghcr.io/${{ steps.repo_owner.outputs.repo_owner }}/hlds:${{ matrix.game }}-${{ needs.version.outputs.version }}
IMAGE=ghcr.io/${{ env.repo_owner }}/hlds:${{ matrix.game }}-${{ needs.version.outputs.version }}
publish:
name: Publish GitHub Release 🚀
needs: build
runs-on: ubuntu-latest
permissions:
Expand Down
Loading

0 comments on commit a2fe226

Please sign in to comment.