Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use hetzner ephemeral runners for hcloud-dev deployment #899

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 }}
Loading