9
9
runner_token :
10
10
description : >-
11
11
GitHub auth token, needs `repo`/`public_repo` scope: https://docs.github.com/en/rest/reference/actions#self-hosted-runners.
12
- required : true
13
- project_id :
12
+ required : true
13
+ project_id :
14
14
description : >-
15
15
ID of the Google Cloud Platform project. If provided, this will configure gcloud to use this project ID.
16
16
required : false
@@ -51,6 +51,9 @@ inputs:
51
51
description : Additional context about the workflow
52
52
default : default
53
53
required : true
54
+ gcp_credentials :
55
+ description : GCP JSON credentials
56
+ required : true
54
57
55
58
outputs :
56
59
label :
@@ -71,21 +74,43 @@ runs:
71
74
run : |
72
75
echo "❌ Job actions are not allowed to run in forks" >> $GITHUB_STEP_SUMMARY
73
76
exit 1
77
+ - uses : actions/checkout@v3
78
+ - id : auth
79
+ name : Authenticate to Google Cloud
80
+ uses : google-github-actions/auth@v1
81
+ with :
82
+ credentials_json : ${{ inputs.gcp_credentials }}
83
+ - id : gcloud-auth
84
+ name : gcloud auth activate-service-account
85
+ shell : bash
86
+ run : |
87
+ gcloud auth activate-service-account --key-file ${{ steps.auth.outputs.credentials_file_path }}
74
88
- id : gce-github-runner-script
75
89
if : github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name
76
- shell : bash
77
- run : >
78
- ${{ github.action_path }}/action.sh
79
- --command=start
80
- --runner_token=${{ inputs.runner_token }}
81
- --project_id=${{ inputs.project_id }}
82
- --machine_zone=${{ inputs.machine_zone }}
83
- --machine_type=${{ inputs.machine_type }}
84
- --disk_size=${{ inputs.disk_size }}
85
- --scopes=${{ inputs.scopes }}
86
- --shutdown_timeout=${{ inputs.shutdown_timeout }}
87
- --image_project=${{ inputs.image_project }}
88
- --image=${{ inputs.image }}
89
- --image_family=${{ inputs.image_family }}
90
- --boot_disk_type=pd-ssd
91
- --task=${{ inputs.task }}
90
+ uses : pyTooling/Actions/with-post-step@r0
91
+ with :
92
+ main : |
93
+ ${{ github.action_path }}/action.sh
94
+ --command=start
95
+ --runner_token=${{ inputs.runner_token }}
96
+ --project_id=${{ inputs.project_id }}
97
+ --machine_zone=${{ inputs.machine_zone }}
98
+ --machine_type=${{ inputs.machine_type }}
99
+ --disk_size=${{ inputs.disk_size }}
100
+ --scopes=${{ inputs.scopes }}
101
+ --shutdown_timeout=${{ inputs.shutdown_timeout }}
102
+ --image_project=${{ inputs.image_project }}
103
+ --image=${{ inputs.image }}
104
+ --image_family=${{ inputs.image_family }}
105
+ --boot_disk_type=pd-ssd
106
+ --task=${{ inputs.task }}
107
+ post : |
108
+ echo "Removing GCE VM..."
109
+
110
+ gcloud auth activate-service-account --key-file ${{ steps.auth.outputs.credentials_file_path }}
111
+ if [ -z "$(gcloud compute instances list | grep "${{ inputs.runner-label }}")" ]; then
112
+ # vm is gone
113
+ exit 0
114
+ fi
115
+
116
+ gcloud compute instances delete ${{ inputs.runner-label }} --quiet --zone ${{ inputs.machine-zone }}
0 commit comments