Skip to content

Commit

Permalink
feat: use hetzner ephemeral runners for hcloud-dev deployment (#899)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnae authored Oct 8, 2024
1 parent 5794da9 commit 7eac525
Showing 1 changed file with 36 additions and 3 deletions.
39 changes: 36 additions & 3 deletions .github/workflows/hcloud-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,31 @@ name: Hcloud Dev

on:
workflow_dispatch: {}
# schedule:
# - cron: '0 6 * * MON,TUE,WED,THU,FRI'
schedule:
- cron: '0 6 * * MON,TUE,WED,THU,FRI'

jobs:
create-runner:
name: Create Hetzner Cloud Runner
runs-on: ubuntu-latest
outputs:
server-name: ${{ steps.create-runner.outputs.server-name }}
steps:
name: Create Hetzner Runner
id: create-runner
uses: Kwarf/hetzner-ephemeral-runner@v1
with:
action: create
github-token: ${{ secrets.GH_TOKEN_HETZNER_RUNNER }}
hetzner-token: ${{ secrets.HCLOUD_TOKEN }}
server-location: hel1

start:
permissions:
contents: read
id-token: write
runs-on: ubuntu-latest
needs: create-runner
runs-on: ${{ needs.create-runner.outputs.server-name }}
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -40,6 +56,7 @@ jobs:
CLOUD_DISK_PASSWORD: ${{ secrets.CLOUD_DISK_PASSWORD }}
HCLOUD_DEV_SSH_HOSTKEY: ${{ secrets.HCLOUD_DEV_SSH_HOSTKEY }}
HCLOUD_DEV_SSH_INITRD_KEY: ${{ secrets.HCLOUD_DEV_SSH_INITRD_KEY }}
TF_VAR_server_type: CX22
run: |
TF_VAR_kexec_tarball="$(nix build .#kexec-installer-nixos-unstable-noninteractive --print-out-paths --no-link)/nixos-kexec-installer-noninteractive-x86_64-linux.tar.gz"
export TF_VAR_kexec_tarball
Expand All @@ -55,3 +72,19 @@ jobs:
REMOTE_IP: ${{ steps.tofu.outputs.remote_ip }}
run: |
nix run .#unlockremote
remove-runner:
name: Remove runner
needs:
- create-runner
- start
runs-on: ubuntu-latest
if: ${{ always() }}
steps:
- name: Remove runner
uses: Kwarf/hetzner-ephemeral-runner@v1
with:
action: remove
github-token: ${{ secrets.GH_TOKEN_HETZNER_RUNNER }}
hetzner-token: ${{ secrets.HCLOUD_TOKEN }}
server-name: ${{ needs.create-runner.outputs.server-name }}

0 comments on commit 7eac525

Please sign in to comment.