Skip to content

Commit

Permalink
add teardown procedure
Browse files Browse the repository at this point in the history
  • Loading branch information
kk-min committed Apr 26, 2024
1 parent fa2630e commit 5a71f33
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 3 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/provision-test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
name: Provision Test GCR
on: push

jobs:
setup-gcr-vm:
Expand Down Expand Up @@ -31,7 +30,7 @@ jobs:
GH_TOKEN: ${{ secrets.DEPLOY_SELF_HOSTED_RUNNER_TOKEN }}
id: get-registration-token

- name: Create GCR VM
- name: Create GCloud Compute Engine VM
run: gcloud compute instances create github-actions-runner-gcr --zone=us-west1-a --image=stellar-continuous-gcr-disk --image-project=stellar-benchmarking

- name: Setup self-hosted runner
Expand All @@ -46,6 +45,6 @@ jobs:
mkdir actions-runner && cd actions-runner &&
curl -o actions-runner-linux-x64-2.315.0.tar.gz -L https://github.com/actions/runner/releases/download/v2.315.0/actions-runner-linux-x64-2.315.0.tar.gz &&
tar xzf ./actions-runner-linux-x64-2.315.0.tar.gz &&
printf "\n\ngcr\n" | ./config.sh --url https://github.com/vhive-serverless/STeLLAR --token ${{ steps.get-registration-token.outputs.token }} &&
printf "\nstellar-continuous-gcr\ngcr\n" | ./config.sh --url https://github.com/vhive-serverless/STeLLAR --token ${{ steps.get-registration-token.outputs.token }} &&
tmux new-session -d -s github-actions-runner-gcr "bash ./run.sh"
'
44 changes: 44 additions & 0 deletions .github/workflows/teardown-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Teardown GCR VM Test
on: push

jobs:
teardown-gcr-vm:
runs-on: ubuntu-latest
permissions: write-all
steps:
- uses: actions/checkout@v4

- id: auth
name: Configure GCR credentials
uses: google-github-actions/auth@v1
with:
credentials_json: ${{ secrets.GCR_CREDENTIALS }}

- name: Set up gcloud
uses: google-github-actions/setup-gcloud@v1
with:
version: ">= 363.0.0"

- name: Get self-hosted runner ID
id: get-runner-id
env:
GH_TOKEN: ${{ secrets.DEPLOY_SELF_HOSTED_RUNNER_TOKEN }}
run: |
gh api \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/vhive-serverless/STeLLAR/actions/runners \
| echo id=$(jq '.runners[] | select(.name == "github-actions-runner-gcr") | .id') > $GITHUB_OUTPUT
- name: Remove self-hosted runner
env:
GH_TOKEN: ${{ secrets.DEPLOY_SELF_HOSTED_RUNNER_TOKEN }}
run: |
gh api \
--method DELETE \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/vhive-serverless/STeLLAR/actions/runners/${{ steps.get-runner-id.outputs.id }}
- name: Delete GCloud Compute Engine VM
run: gcloud compute instances delete github-actions-runner-gcr --zone=us-west1-a

0 comments on commit 5a71f33

Please sign in to comment.