Repository navigation
243 lines (212 loc) · 9.77 KB
/
Copy pathgametracking.yml
File metadata and controls
243 lines (212 loc) · 9.77 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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
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: true
reset-gametracking:
required: false
type: boolean
default: false
dumpsource2-schema-json:
required: false
type: string
default: ''
dispatch-source2wiki:
required: false
type: boolean
default: false
secrets:
STEAM_USERNAME:
required: true
STEAM_PASSWORD:
required: true
jobs:
gametracking-setup:
runs-on: ${{ inputs.run-on-windows && 'windows-latest' || 'ubuntu-latest' }}
# Permissions come from the calling job: contents and statuses write, plus id-token write for commit summaries with Workload Identity Federation.
# Requesting id-token here would fail the whole run for callers that do not grant it.
steps:
# Checkout and download tools
- name: Checkout shared GameTracking
uses: actions/checkout@v7
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@v7
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@v7
with:
node-version: '24'
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 track --username "${{ secrets.STEAM_USERNAME }}" --password "${{ secrets.STEAM_PASSWORD }}" --appid "${{ inputs.appid }}" --output . --branch "${{ inputs.branch }}" ${{ inputs.save-manifest && '--save-all-manifests' || '' }}
- name: Run update script
id: update
continue-on-error: true
working-directory: ${{ github.workspace }}/tracked_game
shell: bash
run: |
unset "${!ACTIONS_@}"
./update.sh
# Post-processing
- name: Set commit status
if: always() && steps.before.outputs.sha
id: set-status
continue-on-error: true
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" && "${{ steps.update.outcome }}" == "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: Create SchemaExplorer token
id: schemaexplorer-token
if: ${{ inputs.dumpsource2-schema-json != '' && github.repository_owner == 'SteamTracking' && github.ref_name == github.event.repository.default_branch && steps.before.outputs.sha != steps.set-status.outputs.sha }}
uses: actions/create-github-app-token@v3
with:
client-id: ${{ secrets.STEAMTRACKING_APP_CLIENT_ID }}
private-key: ${{ secrets.STEAMTRACKING_APP_PRIVATE_KEY }}
owner: ValveResourceFormat
repositories: SchemaExplorer
permission-contents: write
- name: Checkout DumpSource2 JSON Repo
if: ${{ inputs.dumpsource2-schema-json != '' && github.repository_owner == 'SteamTracking' && github.ref_name == github.event.repository.default_branch && steps.before.outputs.sha != steps.set-status.outputs.sha }}
uses: actions/checkout@v7
with:
fetch-depth: 1
path: dumps2_json
repository: 'ValveResourceFormat/SchemaExplorer'
token: ${{ steps.schemaexplorer-token.outputs.token }}
- name: Push DumpSource2 JSON
if: ${{ inputs.dumpsource2-schema-json != '' && github.repository_owner == 'SteamTracking' && github.ref_name == github.event.repository.default_branch && steps.before.outputs.sha != steps.set-status.outputs.sha }}
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: Create Protobufs token
id: protobufs-token
if: ${{ github.repository_owner == 'SteamTracking' && github.ref_name == github.event.repository.default_branch }}
continue-on-error: true
uses: actions/create-github-app-token@v3
with:
client-id: ${{ secrets.STEAMTRACKING_APP_CLIENT_ID }}
private-key: ${{ secrets.STEAMTRACKING_APP_PRIVATE_KEY }}
owner: SteamTracking
repositories: Protobufs
permission-contents: write
- name: Dispatch sync to ValveProtobufs
if: ${{ github.repository_owner == 'SteamTracking' && github.ref_name == github.event.repository.default_branch }}
continue-on-error: true
run: gh api repos/SteamTracking/Protobufs/dispatches -f event_type=sync
env:
GH_TOKEN: ${{ steps.protobufs-token.outputs.token }}
- name: Dispatch app-update to Source2Wiki
if: ${{ inputs.dispatch-source2wiki && env.GH_TOKEN != '' && github.ref_name == github.event.repository.default_branch && steps.before.outputs.sha != steps.set-status.outputs.sha }}
continue-on-error: true
run: gh api repos/Source2Wiki/Source2Wiki/dispatches -f event_type=app-update -F "client_payload[owner]={owner}" -F "client_payload[repo]={repo}"
env:
GH_TOKEN: ${{ secrets.DISPATCH_TOKEN_SOURCE2WIKI }}
- name: Summarize commit
id: summary
if: ${{ (env.ANTHROPIC_FEDERATION_RULE_ID != '' || env.CLAUDE_CODE_OAUTH_TOKEN != '') && steps.set-status.outputs.sha && steps.before.outputs.sha != steps.set-status.outputs.sha }}
continue-on-error: true
timeout-minutes: 120
uses: ./.github/actions/commit-summary
with:
sha: ${{ steps.set-status.outputs.sha }}
env:
ANTHROPIC_FEDERATION_RULE_ID: ${{ secrets.ANTHROPIC_FEDERATION_RULE_ID }}
ANTHROPIC_ORGANIZATION_ID: ${{ secrets.ANTHROPIC_ORGANIZATION_ID }}
ANTHROPIC_SERVICE_ACCOUNT_ID: ${{ secrets.ANTHROPIC_SERVICE_ACCOUNT_ID }}
CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
- name: Fail if update script or commit summary failed
if: ${{ steps.update.outcome == 'failure' || steps.summary.outcome == 'failure' }}
run: exit 1