-
Notifications
You must be signed in to change notification settings - Fork 41
185 lines (160 loc) · 6.43 KB
/
gametracking.yml
File metadata and controls
185 lines (160 loc) · 6.43 KB
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
name: GameTracking
on:
workflow_call:
inputs:
appid:
required: true
type: string
branch:
required: false
type: string
default: 'public'
run-on-windows:
required: false
type: boolean
default: false
save-manifest:
required: false
type: boolean
default: false
reset-gametracking:
required: false
type: boolean
default: false
dumpsource2-schema-json:
required: false
type: string
default: ''
secrets:
STEAM_USERNAME:
required: true
STEAM_PASSWORD:
required: true
jobs:
gametracking-setup:
runs-on: ${{ inputs.run-on-windows && 'windows-latest' || 'ubuntu-latest' }}
permissions:
contents: write
statuses: write
steps:
# Checkout and download tools
- name: Checkout shared GameTracking
uses: actions/checkout@v6
with:
fetch-depth: 1
repository: 'SteamTracking/GameTracking'
- name: Download pre-built tools
shell: bash
run: |
if [[ "$(uname -s)" == MINGW* ]] || [[ "$(uname -s)" == MSYS* ]]; then
ARCHIVE="tools-win-x64.tar.gz"
else
ARCHIVE="tools-linux-x64.tar.gz"
fi
gh release download tools \
--repo SteamTracking/GameTracking \
--pattern "$ARCHIVE" \
--dir .
tar xzf "$ARCHIVE" -C tools/
rm "$ARCHIVE"
env:
GH_TOKEN: ${{ github.token }}
- name: Checkout game repository (${{ github.repository }})
uses: actions/checkout@v6
with:
fetch-depth: 1
path: tracked_game
# Optional Node.js setup
- name: Check for package-lock.json
id: package-lock-json-exists
shell: bash
run: echo "exists=$(test -f ${{ github.workspace }}/tracked_game/package-lock.json && echo true || echo false)" >> $GITHUB_OUTPUT
- name: Setup Node.js
if: steps.package-lock-json-exists.outputs.exists == 'true'
uses: actions/setup-node@v6
with:
node-version: '22'
cache: 'npm'
cache-dependency-path: ${{ github.workspace }}/tracked_game/package-lock.json
- name: Install Node.js dependencies
if: steps.package-lock-json-exists.outputs.exists == 'true'
working-directory: ${{ github.workspace }}/tracked_game
run: npm ci
# Download and process
- name: Configure git user
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global core.safecrlf false
- name: Get current commit SHA
id: before
working-directory: ${{ github.workspace }}/tracked_game
shell: bash
run: echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
- name: Delete all folders for cleanup
if: ${{ inputs.reset-gametracking }}
working-directory: ${{ github.workspace }}/tracked_game
shell: bash
run: |
find . -mindepth 1 -maxdepth 1 -type d \
! -name 'node_modules' \
! -name '.git' \
! -name '.github' \
-exec rm -rf {} \;
- name: Download app ${{ inputs.appid }}
working-directory: ${{ github.workspace }}/tracked_game
shell: bash
run: |
. ../common.sh
$STEAM_FILE_DOWNLOADER_PATH --username "${{ secrets.STEAM_USERNAME }}" --password "${{ secrets.STEAM_PASSWORD }}" --appid "${{ inputs.appid }}" --output . --branch "${{ inputs.branch }}" ${{ inputs.save-manifest && '--save-manifest' || '' }}
- name: Run update script
working-directory: ${{ github.workspace }}/tracked_game
shell: bash
run: ./update.sh
# Post-processing
- name: Set commit status
if: always() && steps.before.outputs.sha
id: set-status
working-directory: ${{ github.workspace }}/tracked_game
shell: bash
run: |
NEW_SHA=$(git rev-parse HEAD)
echo "sha=$NEW_SHA" >> $GITHUB_OUTPUT
if [[ "$NEW_SHA" == "${{ steps.before.outputs.sha }}" ]]; then
echo "No new commit was pushed, skipping status"
exit 0
fi
if [[ "${{ job.status }}" == "success" ]]; then
STATE="success"
else
STATE="failure"
fi
gh api "repos/${{ github.repository }}/statuses/$NEW_SHA" \
-f state="$STATE" \
-f target_url="$GITHUB_SERVER_URL/${{ github.repository }}/actions/runs/${{ github.run_id }}" \
-f description="GameTracking" \
-f context="GameTracking"
env:
GH_TOKEN: ${{ github.token }}
- name: Checkout DumpSource2 JSON Repo
if: ${{ inputs.dumpsource2-schema-json != '' && github.ref_name == github.event.repository.default_branch }}
uses: actions/checkout@v6
with:
fetch-depth: 1
path: dumps2_json
repository: 'ValveResourceFormat/SchemaExplorer'
token: ${{ secrets.DUMPSOURCE2_EXPLORER_TOKEN }}
- name: Push DumpSource2 JSON
if: ${{ inputs.dumpsource2-schema-json != '' && github.ref_name == github.event.repository.default_branch }}
working-directory: ${{ github.workspace }}/dumps2_json/schemas
shell: bash
run: |
"${{ github.workspace }}/tools/push_schema_json.sh" \
"${{ inputs.dumpsource2-schema-json }}" \
"${{ github.workspace }}/tracked_game" \
"https://github.com/${{ github.repository }}/commit/${{ steps.set-status.outputs.sha }}"
- name: Dispatch sync to ValveProtobufs
if: ${{ env.GH_TOKEN != '' && github.ref_name == github.event.repository.default_branch }}
run: gh api repos/SteamTracking/Protobufs/dispatches -f event_type=sync
env:
GH_TOKEN: ${{ secrets.DISPATCH_TOKEN }}