Skip to content

Commit

Permalink
Fix shutdown sleep and service account
Browse files Browse the repository at this point in the history
  • Loading branch information
ravwojdyla committed Jun 28, 2021
1 parent c56ba46 commit 632fb57
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
5 changes: 2 additions & 3 deletions action.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ do
disk_size=$OPTLARG
;;
runner_service_account)
runner_service_account=$OPTLARG
runner_service_account=${OPTLARG-$runner_service_account}
;;
scopes)
scopes=$OPTLARG
Expand Down Expand Up @@ -155,11 +155,10 @@ function stop_vm {
# to do that. VM shutdown will disconnect the runner, and GH will unregister it
# in 30 days
# TODO: RUNNER_ALLOW_RUNASROOT=1 /actions-runner/config.sh remove --token $TOKEN
safety_off
NAME=$(curl -S -s -X GET http://metadata.google.internal/computeMetadata/v1/instance/name -H 'Metadata-Flavor: Google')
ZONE=$(curl -S -s -X GET http://metadata.google.internal/computeMetadata/v1/instance/zone -H 'Metadata-Flavor: Google')
echo "✅ Self deleting $NAME in $ZONE in ${shutdown_timeout} seconds ..."
echo "sleep ${shutdown_timeout}; gcloud --quiet compute instances delete $NAME --zone=$ZONE" | at now
echo "sleep ${shutdown_timeout}; gcloud --quiet compute instances delete $NAME --zone=$ZONE" | env -i at now
}

safety_on
Expand Down
25 changes: 13 additions & 12 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ inputs:
required: true
runner_service_account:
description: Service account of the VM, defaults to default compute service account.
required: false
default: ''
required: true
scopes:
description: Scopes granted to the VM, defaults to full access (cloud-platform).
default: cloud-platform
Expand All @@ -64,15 +65,15 @@ runs:
- id: gce-github-runner-script
run: >
${{ github.action_path }}/action.sh
--command ${{ inputs.command }}
--token ${{ inputs.token }}
--project_id ${{ inputs.project_id }}
--service_account_key '${{ inputs.service_account_key }}'
--runner_ver ${{ inputs.runner_ver }}
--machine_zone ${{ inputs.machine_zone }}
--machine_type ${{ inputs.machine_type }}
--disk_size ${{ inputs.disk_size }}
--scopes ${{ inputs.scopes }}
--shutdown_timeout ${{ inputs.shutdown_timeout }}
--runner_service_account ${{ inputs.runner_service_account }}
--command=${{ inputs.command }}
--token=${{ inputs.token }}
--project_id=${{ inputs.project_id }}
--service_account_key='${{ inputs.service_account_key }}'
--runner_ver=${{ inputs.runner_ver }}
--machine_zone=${{ inputs.machine_zone }}
--machine_type=${{ inputs.machine_type }}
--disk_size=${{ inputs.disk_size }}
--scopes=${{ inputs.scopes }}
--shutdown_timeout=${{ inputs.shutdown_timeout }}
--runner_service_account=${{ inputs.runner_service_account }}
shell: bash

0 comments on commit 632fb57

Please sign in to comment.