Build and Push #105
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Push | |
on: | |
workflow_dispatch: | |
inputs: | |
tag_name: | |
description: "Tag name for the Docker image (or version tag)" | |
required: true | |
release: | |
type: boolean | |
description: "Is this a full release?" | |
required: true | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Get docker-slim | |
run: | | |
SLIM_VERSION=1.40.10 | |
curl -L -o ds.tar.gz https://downloads.dockerslim.com/releases/$SLIM_VERSION/dist_linux.tar.gz | |
tar -xvzf ds.tar.gz | |
mv dist_linux/* $GITHUB_WORKSPACE | |
rm -rfv ds.tar.gz dist_linux/ | |
- name: Build starter images | |
run: | | |
cd $GITHUB_WORKSPACE/docker | |
GLUATEST_REF=${{ inputs.tag_name }} | |
docker build --build-arg="GMOD_BRANCH=live" --build-arg="GLUATEST_REF=$GLUATEST_REF" --tag gluatest_fat_live:latest . | |
docker build --build-arg="GMOD_BRANCH=x86-64" --build-arg="GLUATEST_REF=$GLUATEST_REF" --tag gluatest_fat_x86-64:latest . | |
- name: Discern Game Versions | |
run: | | |
# Create temporary containers | |
publicID=$(docker create gluatest_fat_live:latest) | |
x86ID=$(docker create gluatest_fat_x86-64:latest) | |
# Copy their manifest files | |
docker cp $publicID:/home/steam/gmodserver/steamapps/appmanifest_4020.acf $GITHUB_WORKSPACE/appmanifest_public.acf | |
docker cp $x86ID:/home/steam/gmodserver/steamapps/appmanifest_4020.acf $GITHUB_WORKSPACE/appmanifest_x86.acf | |
# Remove temporary containers | |
docker rm $publicID $x86ID | |
# Extract the version | |
cat $GITHUB_WORKSPACE/appmanifest_public.acf | grep "buildid\"" | awk -F '"' '/"buildid"/ {print $4}' > $GITHUB_WORKSPACE/gmod_buildid_public.txt | |
cat $GITHUB_WORKSPACE/appmanifest_x86.acf | grep "buildid\"" | awk -F '"' '/"buildid"/ {print $4}' > $GITHUB_WORKSPACE/gmod_buildid_x86.txt | |
rm $GITHUB_WORKSPACE/appmanifest_public.acf $GITHUB_WORKSPACE/appmanifest_x86.acf | |
echo "Public BuildID: $(cat $GITHUB_WORKSPACE/gmod_buildid_public.txt)" | |
echo "x86-64 BuildID: $(cat $GITHUB_WORKSPACE/gmod_buildid_x86.txt)" | |
- name: Make slim images | |
run: | | |
cd $GITHUB_WORKSPACE/docker | |
BASE=ghcr.io/cfc-servers/gluatest | |
rawVersionTag=${{ inputs.tag_name }} | |
publicID=$(cat $GITHUB_WORKSPACE/gmod_buildid_public.txt) | |
$GITHUB_WORKSPACE/docker-slim build \ | |
--target gluatest_fat_live:latest \ | |
--remove-file-artifacts \ | |
--http-probe-off \ | |
--continue-after 30 \ | |
--show-clogs --show-blogs \ | |
--tag $BASE:$rawVersionTag \ | |
--tag $BASE:gamebuild-$publicID | |
x86ID=$(cat $GITHUB_WORKSPACE/gmod_buildid_x86.txt) | |
$GITHUB_WORKSPACE/docker-slim build \ | |
--target gluatest_fat_x86-64:latest \ | |
--remove-file-artifacts \ | |
--http-probe-off \ | |
--continue-after 30 \ | |
--show-clogs --show-blogs \ | |
--tag $BASE/64bit:$rawVersionTag \ | |
--tag $BASE/64bit:gamebuild-$x86ID | |
# Tag image with "0.27" if we push tag "0.27.5" | |
# but not if we push tag "0.27-pre5" | |
parentMinorVersion=${rawVersionTag%.*} | |
if [[ $parentMinorVersion != "0" ]]; then | |
echo "::warning:: Tagging with parent minor version: $parentMinorVersion" | |
docker tag $BASE:$rawVersionTag $BASE:$parentMinorVersion | |
docker tag $BASE/64bit:$rawVersionTag $BASE/64bit:$parentMinorVersion | |
fi | |
if [ "${{ inputs.release }}" = "true" ]; then | |
echo "::warning:: Tagging this release as the latest!" | |
docker tag $BASE:$rawVersionTag $BASE:latest | |
docker tag $BASE/64bit:$rawVersionTag $BASE/64bit:latest | |
fi | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.GH_TOKEN }} | |
- name: Tag and push slim images | |
run: | | |
docker push ghcr.io/cfc-servers/gluatest --all-tags | |
docker push ghcr.io/cfc-servers/gluatest/64bit --all-tags |