-
-
Notifications
You must be signed in to change notification settings - Fork 1
66 lines (65 loc) · 2.5 KB
/
vm-startup-script.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
56
57
58
59
60
61
62
63
64
65
66
# Virtual Machine Startup Script
#
# Upload virtual machine startup script when on startup script file modification, workflow call, or
# workflow dispatch.
#
# References:
#
# - https://cloud.google.com/compute/docs/instances/startup-scripts/linux
# - https://cloud.google.com/sdk/gcloud/reference/compute/instances/add-metadata
# - https://docs.github.com/actions/using-workflows/events-that-trigger-workflows#push
# - https://docs.github.com/actions/using-workflows/events-that-trigger-workflows#workflow_call
# - https://docs.github.com/actions/using-workflows/events-that-trigger-workflows#workflow_dispatch
# - https://docs.github.com/actions/using-workflows/reusing-workflows
# - https://docs.github.com/webhooks-and-events/webhooks/webhook-events-and-payloads#push
# - https://docs.github.com/webhooks-and-events/webhooks/webhook-events-and-payloads#workflow_dispatch
# - https://github.com/actions/checkout
# - https://github.com/google-github-actions/auth
# - https://github.com/google-github-actions/setup-gcloud
# - https://github.com/hmarr/debug-action
---
name: vm-startup-script
on:
push:
branches:
- main
paths:
- .github/workflows/vm-startup-script.yml
- scripts/vm/startup-script.sh
workflow_call:
workflow_dispatch:
env:
CLOUDSDK_COMPUTE_ZONE: ${{ secrets.CLOUDSDK_COMPUTE_ZONE }}
concurrency:
cancel-in-progress: true
group: vm-startup-script-${{ github.ref }}
jobs:
vm-startup-script:
if: github.event_name != 'push' || !startsWith(github.event.head_commit.message, 'release:')
runs-on: ubuntu-latest
steps:
- id: debug
name: Print environment variables and event payload
uses: hmarr/debug-action@v2.1.0
- id: checkout
name: Checkout ${{ github.ref_name }}
uses: actions/checkout@v3.5.2
with:
ref: ${{ github.ref }}
- id: gcloud-auth
name: Authenticate to Google Cloud
uses: google-github-actions/auth@v1.1.0
with:
credentials_json: ${{ secrets.GCE_SERVICE_ACCOUNT }}
project_id: ${{ secrets.CLOUDSDK_CORE_PROJECT }}
- id: gcloud-setup
name: Set up Google Cloud SDK
uses: google-github-actions/setup-gcloud@v1.1.0
with:
project_id: ${{ secrets.CLOUDSDK_CORE_PROJECT }}
skip_install: true
- id: startup-script
name: Upload startup-script metadata
run: |
gcloud compute instances add-metadata ${{ secrets.VM }} \
--metadata-from-file=startup-script=./scripts/vm/startup-script.sh