-
-
Notifications
You must be signed in to change notification settings - Fork 4
109 lines (89 loc) · 4.13 KB
/
build_and_push.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
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 \
--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 \
--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: ${{ github.actor }}
password: ${{ secrets.GITHUB_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