@@ -173,6 +173,12 @@ cleanup() {
173
173
trap 'cleanup; exit 130' INT
174
174
trap 'cleanup; exit 143' TERM
175
175
176
+ on_error() {
177
+ echo "Error on line \$ (caller)"
178
+ }
179
+
180
+ trap on_error ERR
181
+
176
182
cat <<-EOF >/etc/environment
177
183
PATH="/home/runner/go-packages/bin:/home/runner/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin"
178
184
GOPATH="/home/runner/go-packages"
188
194
189
195
chmod +x /etc/systemd/system/shutdown.sh
190
196
197
+ echo "Registering runners ${RUNNER_ID} -1 and ${RUNNER_ID} -2..."
191
198
su -s /bin/bash -c "cd /actions-runner-1/;/actions-runner-1/config.sh --url https://github.com/${GITHUB_REPOSITORY} --token ${RUNNER_TOKEN} --name ${RUNNER_ID} -1 --labels ${VM_ID} --unattended --disableupdate" runner
192
199
su -s /bin/bash -c "cd /actions-runner-2/;/actions-runner-2/config.sh --url https://github.com/${GITHUB_REPOSITORY} --token ${RUNNER_TOKEN} --name ${RUNNER_ID} -2 --labels ${VM_ID} --unattended --disableupdate" runner
193
200
@@ -203,19 +210,21 @@ FILE_EOF
203
210
204
211
set -e
205
212
206
- echo "Removing runner..."
207
- REMOVE_TOKEN=\$ (curl \
208
- -X POST \
209
- -H "Accept: application/vnd.github+json" \
210
- -H "Authorization: Bearer ${RUNNER_TOKEN} " \
211
- https://api.github.com/repos/${GITHUB_REPOSITORY} /actions/runners/remove-token | jq .token --raw-output)
212
- if [ -z "\$ REMOVE_TOKEN" ]; then
213
- echo "❌ Failed to get a removal token"
214
- exit 0
215
- fi
216
-
217
- su -s /bin/bash -c "cd /actions-runner-1/;/actions-runner-1/config.sh remove --token \$ {REMOVE_TOKEN}" runner
218
- su -s /bin/bash -c "cd /actions-runner-2/;/actions-runner-2/config.sh remove --token \$ {REMOVE_TOKEN}" runner
213
+ on_error() {
214
+ echo "Error on line \$ (caller)"
215
+ }
216
+
217
+ trap on_error ERR
218
+
219
+ echo "Removing runners ${RUNNER_ID} -1 and ${RUNNER_ID} -2..."
220
+
221
+ cd /actions-runner-1/
222
+ su -s /bin/bash -c "/actions-runner-1/config.sh remove --token ${RUNNER_TOKEN} " runner
223
+
224
+ cd /actions-runner-2/
225
+ su -s /bin/bash -c "/actions-runner-2/config.sh remove --token ${RUNNER_TOKEN} " runner
226
+
227
+ echo "Removed runners"
219
228
220
229
FILE_EOF
221
230
0 commit comments