-
Notifications
You must be signed in to change notification settings - Fork 0
55 lines (53 loc) · 1.72 KB
/
create-vm.yml
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
name: Create GCE VM
on:
workflow_call:
inputs:
task:
type: string
required: false
default: "default"
# If set, use this label instead of generating a random one (and 'task' will be ignored).
# Useful to recreate a runner VM that got shutdown.
label:
type: string
required: false
default: ""
secrets:
gcp_credentials:
required: true
runner_token:
required: true
outputs:
label:
value: ${{ jobs.run.outputs.label }}
machine-zone:
value: ${{ jobs.run.outputs.machine-zone }}
jobs:
run:
name: Create GCE VM
runs-on: ubuntu-latest
outputs:
label: ${{ steps.create-runner.outputs.label }}
machine-zone: ${{ steps.create-runner.outputs.machine-zone }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Authenticate to Google Cloud
id: auth
if: github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name
uses: google-github-actions/auth@v1
with:
credentials_json: ${{ secrets.gcp_credentials }}
- name: Activate GCP service account
id: gcloud-auth
if: github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name
shell: bash
run: |
gcloud auth activate-service-account --key-file ${{ steps.auth.outputs.credentials_file_path }}
- id: create-runner
uses: gitpod-io/gce-github-runner@main
with:
runner_token: ${{ secrets.runner_token }}
task: ${{ inputs.task }}
label: ${{ inputs.label }}
gcp_credentials: ${{ secrets.gcp_credentials }}