@@ -10,6 +10,10 @@ runner_configured="false"
1010runner_exit_code=0
1111runner_exec_mode=" runner"
1212RUNNER_AUDIT_DEREGISTER_EVENT=" runner_deregistered"
13+ github_pat_for_cleanup=" "
14+ github_app_id_for_cleanup=" "
15+ github_app_installation_id_for_cleanup=" "
16+ github_app_private_key_for_cleanup=" "
1317
1418run_runner_bash () {
1519 local command=" $1 "
@@ -81,7 +85,23 @@ prepare_runner_home() {
8185}
8286
8387cleanup_runner () {
88+ export GITHUB_PAT=" ${github_pat_for_cleanup} "
89+ export GITHUB_APP_ID=" ${github_app_id_for_cleanup} "
90+ export GITHUB_APP_INSTALLATION_ID=" ${github_app_installation_id_for_cleanup} "
91+ export GITHUB_APP_PRIVATE_KEY=" ${github_app_private_key_for_cleanup} "
8492 cleanup_runner_registration " run_runner_bash \" cd '${RUNNER_HOME} ' && ./config.sh remove --token \\\"\\\$ {RUNNER_REMOVE_TOKEN}\\\"\" "
93+ unset GITHUB_PAT GITHUB_APP_ID GITHUB_APP_INSTALLATION_ID GITHUB_APP_PRIVATE_KEY
94+ }
95+
96+ stash_github_auth_for_cleanup () {
97+ github_pat_for_cleanup=" ${GITHUB_PAT:- } "
98+ github_app_id_for_cleanup=" ${GITHUB_APP_ID:- } "
99+ github_app_installation_id_for_cleanup=" ${GITHUB_APP_INSTALLATION_ID:- } "
100+ github_app_private_key_for_cleanup=" ${GITHUB_APP_PRIVATE_KEY:- } "
101+ }
102+
103+ scrub_github_auth_env () {
104+ unset GITHUB_PAT GITHUB_APP_ID GITHUB_APP_INSTALLATION_ID GITHUB_APP_PRIVATE_KEY
85105}
86106
87107prepare_runtime_dirs () {
@@ -165,6 +185,7 @@ trap on_exit EXIT
165185trap ' log "termination requested"; RUNNER_AUDIT_DEREGISTER_EVENT="runner_evicted"; export RUNNER_AUDIT_DEREGISTER_EVENT; exit 0' TERM INT
166186
167187require_github_auth
188+ stash_github_auth_for_cleanup
168189require_env GITHUB_ORG
169190require_env RUNNER_NAME
170191require_env RUNNER_LABELS
@@ -279,5 +300,6 @@ runner_configured="true"
279300audit_event runner_registered
280301
281302log " starting runner ${RUNNER_NAME} "
303+ scrub_github_auth_env
282304run_runner_job_bash " cd '${RUNNER_HOME} ' && exec ./run.sh" \
283305 2>&1 | tee -a " ${RUNNER_LOG_DIR} /runner.log"
0 commit comments