-
-
Notifications
You must be signed in to change notification settings - Fork 6
140 lines (115 loc) · 5.05 KB
/
check_for_updates.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
name: Check for Update
on:
workflow_dispatch:
schedule:
- cron: "18 */12 * * *"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
path: full_repo
- name: Get Latest Tag
id: latest_tag
run: |
cd "$GITHUB_WORKSPACE/full_repo"
latest_tag=$(git describe --tags --abbrev=0 --match='[0-9]*.[0-9]*.[0-9]*' --match='[0-9]*.[0-9]*' --exclude='*[^0-9.]*')
echo "Latest tag: $latest_tag"
echo "tag_name=$latest_tag" >> $GITHUB_OUTPUT
- name: Pull the steamcmd image
run: |
docker pull ghcr.io/cfc-servers/steamcmd-slim:latest
- name: Lookup latest build IDs
id: latest_versions
run: |
docker run \
--rm \
--name version_checker \
ghcr.io/cfc-servers/steamcmd-slim:latest \
/home/steam/steamcmd/steamcmd.sh +login anonymous +app_info_request 4020 +login anonymous +app_info_print 4020 +exit \
> "$GITHUB_WORKSPACE/raw_output.txt"
# Extract just the part we care about
struct=struct.txt
cat "$GITHUB_WORKSPACE/raw_output.txt" | sed -e '1,/"4020"$/ d' > $struct;
# Get the latest build IDs
public=$(grep -A 2 '"public"' $struct | grep '"buildid"' | awk '{print $2}' | sed 's/"//g')
sixtyfour=$(grep -A 2 '"x86-64"' $struct | grep '"buildid"' | awk '{print $2}' | sed 's/"//g')
echo "Latest Public ID: '$public'"
echo "Latest 64bit ID: '$sixtyfour'"
if [ -z "$public" ] || [ -z "$sixtyfour" ]; then
echo "Failed to get the latest build IDs"
echo "Raw Output from SteamCMD:"
cat "$GITHUB_WORKSPACE/raw_output.txt"
exit 1
fi
# Set the output
echo "public=$public" >> $GITHUB_OUTPUT
echo "sixtyfour=$sixtyfour" >> $GITHUB_OUTPUT
- name: Checkout last build branch
uses: actions/checkout@v4
with:
ref: build/last-build-versions
path: build_versions
- name: Read last build IDs
id: last_versions
run: |
public=$(cat $GITHUB_WORKSPACE/build_versions/last_public_build.txt)
sixtyfour=$(cat $GITHUB_WORKSPACE/build_versions/last_64bit_build.txt)
echo "Last Public ID built: '$public'"
echo "Last 64bit ID built: '$sixtyfour'"
echo "public=$public" >> $GITHUB_OUTPUT
echo "sixtyfour=$sixtyfour" >> $GITHUB_OUTPUT
- name: Identify pending updates
id: needs_update
run: |
latest_public=${{ steps.latest_versions.outputs.public }}
last_public=${{ steps.last_versions.outputs.public }}
latest_sixtyfour=${{ steps.latest_versions.outputs.sixtyfour }}
last_sixtyfour=${{ steps.last_versions.outputs.sixtyfour }}
echo "Comparing Public: $latest_public != $last_public"
echo "Comparing 64bit: $latest_sixtyfour != $last_sixtyfour"
public=${{ steps.latest_versions.outputs.public != steps.last_versions.outputs.public }}
sixtyfour=${{ steps.latest_versions.outputs.sixtyfour != steps.last_versions.outputs.sixtyfour }}
echo "Should build Public: '$public'"
echo "Should build 64bit: '$sixtyfour'"
echo "public=$public" >> $GITHUB_OUTPUT
echo "sixtyfour=$sixtyfour" >> $GITHUB_OUTPUT
- name: Update Public Build
if: ${{ steps.needs_update.outputs.public == 'true' }}
uses: ./full_repo/.github/actions/build_and_push
with:
gmod_branch: public
game_version: ${{ steps.latest_versions.outputs.public }}
tag_name: ${{ steps.latest_tag.outputs.tag_name }}
release: true
github_token: ${{ secrets.GITHUB_TOKEN }}
path: $GITHUB_WORKSPACE/full_repo
- name: Update 64bit Build
if: ${{ steps.needs_update.outputs.sixtyfour == 'true' }}
uses: ./full_repo/.github/actions/build_and_push
with:
gmod_branch: x86-64
game_version: ${{ steps.latest_versions.outputs.sixtyfour }}
tag_name: ${{ steps.latest_tag.outputs.tag_name }}
release: true
github_token: ${{ secrets.GITHUB_TOKEN }}
path: $GITHUB_WORKSPACE/full_repo
- name: Update last versions
if: ${{ steps.needs_update.outputs.public == 'true' || steps.needs_update.outputs.sixtyfour == 'true' }}
run: |
cd $GITHUB_WORKSPACE/build_versions
echo ${{ steps.latest_versions.outputs.public }} > ./last_public_build.txt
echo ${{ steps.latest_versions.outputs.sixtyfour }} > ./last_64bit_build.txt
git config user.name github-actions
git config user.email github-actions@github.com
if [[ -z $(git status --porcelain) ]]; then
echo "No changes to commit"
exit 0
else
git add ./last_public_build.txt
git add ./last_64bit_build.txt
git commit -m "Update last build ID(s)"
git push
fi