-
Notifications
You must be signed in to change notification settings - Fork 11
205 lines (184 loc) · 7.24 KB
/
Copy pathdeploy.yaml
File metadata and controls
205 lines (184 loc) · 7.24 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
name: Deploy
on:
push:
branches:
- develop
- master
paths:
- 'src/**'
- '!src/_version.py'
- 'Dockerfile'
- '.github/workflows/deploy.yaml'
- 'poetry.lock'
workflow_dispatch:
inputs:
english-only:
type: boolean
description: Only parse English localizations
default: false
workflow_call:
inputs:
# branch override used by auto-deploy.yaml, as the schedule only runs on the default branch
branch-override:
type: string
required: true
english-only:
type: boolean
default: false
secrets:
GH_TOKEN:
required: true
STEAM_USERNAME:
required: true
STEAM_PASSWORD:
required: true
BOT_WIKI_PASS:
required: true
jobs:
# Each event type has a different variable for the branch name
get-branch:
name: Get branch name
runs-on: ubuntu-latest
outputs:
branch: ${{ steps.branch.outputs.branch }}
steps:
- name: Determine branch name
id: branch
run: |
# override with input branch if it exists
if [[ -n "${{ inputs.branch-override }}" ]]; then
echo "branch=${{ inputs.branch-override }}" >> $GITHUB_OUTPUT
elif [[ "${GITHUB_EVENT_NAME}" == "push" ]]; then
echo "branch=${{ github.ref_name }}" >> $GITHUB_OUTPUT
elif [[ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" ]]; then
echo "branch=${{ github.ref_name }}" >> $GITHUB_OUTPUT
else
echo "branch=INVALID_EVENT_BRANCH_UNKNOWN" >> $GITHUB_OUTPUT
fi
check-branch:
name: Check deadlock-data branch exists
runs-on: ubuntu-latest
needs: get-branch
outputs:
branch_exists: ${{ steps.branch.outputs.branch_exists }}
steps:
- name: Check if deadlock-data branch exists
id: branch
run: |
branch_exists=$(git ls-remote --heads https://${{ secrets.GH_TOKEN }}@github.com/deadlock-wiki/deadlock-data.git refs/heads/${{ needs.get-branch.outputs.branch }})
if [ -z "$branch_exists" ]; then
echo "Branch does not exist, skipping the rest of the job"
echo "branch_exists=false" >> $GITHUB_OUTPUT
else
echo "branch_exists=true" >> $GITHUB_OUTPUT
fi
# Parse game data and commit the parsed output to deadlock-data repo.
# This repo is kept separate to keep the deadbot repo diff cleaner, whilst allowing
# for easy source control and diff viewing
parse:
name: Parse
runs-on: ubuntu-latest
needs: [get-branch, check-branch]
if: ${{ needs.check-branch.outputs.branch_exists == 'true' }}
steps:
- uses: actions/checkout@v7
with:
ref: ${{ needs.get-branch.outputs.branch }}
path: deadbot
token: ${{ secrets.GH_TOKEN }}
- name: Checkout deadlock-data repo
uses: actions/checkout@v7
with:
repository: deadlock-wiki/deadlock-data
path: deadlock-data
token: ${{ secrets.GH_TOKEN }}
- name: Configure Git for deadbot repo
working-directory: deadbot
run: |
git config --global user.email "deadbot1101@gmail.com"
git config --global user.name "Deadbot0"
git config --global --add safe.directory ./data
git config pull.rebase true
- name: Configure Git for data repo
working-directory: deadlock-data
run: |
git config --global user.email "deadbot1101@gmail.com"
git config --global user.name "Deadbot0"
git config pull.rebase true
- name: Switch to same branch name on deadlock-data. If not found, skip job
working-directory: deadlock-data
run: |
git fetch origin ${{ needs.get-branch.outputs.branch }}
git switch ${{ needs.get-branch.outputs.branch }}
continue-on-error: true # Allow the job to stop if this step fails
- uses: docker/setup-buildx-action@v4.2.0
with:
driver: docker-container
- name: Build Deadbot
uses: docker/build-push-action@v7.3.0
with:
context: ./deadbot
file: ./deadbot/Dockerfile
push: false
tags: deadbot:latest
cache-from: |
type=gha,scope=deadbot-master
type=gha,scope=deadbot-${{ needs.get-branch.outputs.branch }}
cache-to: type=gha,mode=max,scope=deadbot-${{ needs.get-branch.outputs.branch }}
load: true
- name: Cache decompiled-data
uses: actions/cache@v6
with:
path: deadbot/decompiled-data
key: deadbot-decompiled-${{ hashFiles('deadbot/src/decompiler/**/*') }}
restore-keys: deadbot-decompiled-
- name: Run Deadbot
working-directory: deadbot
run: docker compose up --exit-code-from deadbot --abort-on-container-exit
env:
IMPORT_FILES: true
ENGLISH_ONLY: ${{ github.event.inputs.english-only == 'true' }}
PARSE_MAP: true
DECOMPILE: true
PARSE: true
CHANGELOGS: true
CLEANUP: false
WIKI_UPLOAD: ${{ needs.get-branch.outputs.branch == 'master' }}
STEAM_USERNAME: ${{ secrets.STEAM_USERNAME }}
STEAM_PASSWORD: ${{ secrets.STEAM_PASSWORD }}
BOT_WIKI_USER: ${{ vars.BOT_WIKI_USER }}
BOT_WIKI_PASS: ${{ secrets.BOT_WIKI_PASS }}
VERBOSE: ${{ secrets.ACTIONS_RUNNER_DEBUG == 'true' }}
- name: Read versions
id: read_versions
working-directory: deadbot
run: |
DEADBOT_VERSION=$(grep -m1 '^version' pyproject.toml | sed 's/version *= *"\(.*\)"/\1/')
echo "deadbot=$DEADBOT_VERSION" >> $GITHUB_OUTPUT
DEADLOCK_VERSION=$(grep '^ClientVersion=' "./decompiled-data/version.txt" | cut -d'=' -f2 | tr -d '\r')
echo "deadlock=$DEADLOCK_VERSION" >> $GITHUB_OUTPUT
DATE=$(grep '^VersionDate=' "./decompiled-data/version.txt" | cut -d'=' -f2 | tr -d '\r')
echo "date=$DATE" >> $GITHUB_OUTPUT
- name: Commit and push input-data changes to deadbot
working-directory: deadbot
run: |
git add input-data
git commit -m "[skip ci] chore: updated input data" || echo "No changes to commit"
git push --force-with-lease origin ${{ needs.get-branch.outputs.branch }}
- name: Pull data branch
working-directory: deadlock-data
run: git pull origin ${{ needs.get-branch.outputs.branch }} -X ours
- name: Copy files to data repo
run: |
cp -r ./deadbot/output-data/. ./deadlock-data/data
- name: Commit and push changes to data repo
working-directory: deadlock-data
env:
DEADBOT_VER: ${{ steps.read_versions.outputs.deadbot }}
DEADLOCK_VER: ${{ steps.read_versions.outputs.deadlock }}
DATE: ${{ steps.read_versions.outputs.date }}
run: |
SHORT_SHA="${GITHUB_SHA::7}"
git add -A
git commit -m "Deadbot v$DEADBOT_VER | Client $DEADLOCK_VER - $DATE (deadbot@${SHORT_SHA})" || echo "No changes to commit"
git push --force-with-lease origin ${{ needs.get-branch.outputs.branch }}