diff --git a/hetzner/README.md b/hetzner/README.md
new file mode 100644
index 0000000..002f840
--- /dev/null
+++ b/hetzner/README.md
@@ -0,0 +1,20 @@
+

Hetzner runner deployments
+
+## Usage
+
+```yaml
+- name: Enable Hetzner Virtual Machines
+ uses: armbian/actions/hetzner@main
+ with:
+ action-type: enable # enable or disable VM cluster
+ machine-type: cax21|cax31|... # machine type
+ machine-id: 0,1,2 ... # selected machine
+ runners-count: 1,2,3 # runners per machine
+ machine-count: 1,2,3 # numbers of machines
+ key: ${{ secrets.KEY_TORRENTS }} # key which we have in the Hezner API
+ known_hosts: ${{ secrets.KNOWN_HOSTS_TORRENTS }} # key_knowns_hosts which we have in the Hezner API
+ hetzner_id: ${{ secrets.HETZNER_ONE }} # hetzner API token
+ github_token: ${{ secrets.ACCESS_TOKEN }} # github action token
+
+```
diff --git a/hetzner/action.yml b/hetzner/action.yml
new file mode 100644
index 0000000..4a91e99
--- /dev/null
+++ b/hetzner/action.yml
@@ -0,0 +1,132 @@
+name: "Enable Hetzner VMs"
+author: "Igor Pecovnik"
+inputs:
+ action-type:
+ required: true
+ machine-type:
+ required: true
+ machine-id:
+ required: false
+ machine-count:
+ required: true
+ runners-count:
+ required: true
+ key:
+ required: true
+ known_hosts:
+ required: true
+ hetzner_id:
+ required: true
+ github_token:
+ required: true
+
+concurrency:
+ cancel-in-progress: false
+
+runs:
+ using: "composite"
+ steps:
+
+ - name: Install SSH key for storage
+ if: ${{ github.repository_owner == 'Armbian' }}
+ uses: shimataro/ssh-key-action@v2
+ with:
+ key: ${{ inputs.key }}
+ known_hosts: ${{ inputs.known_hosts }}
+ if_key_exists: replace
+
+ - name: Install Homebrew
+ if: ${{ github.repository_owner == 'Armbian' }}
+ shell: bash
+ run: |
+
+ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
+ (echo; echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"') >> ${HOME}/.bash_profile
+
+ - name: Install CLI for Hetzner Cloud
+ if: ${{ github.repository_owner == 'Armbian' }}
+ shell: bash
+ env:
+ HCLOUD_TOKEN: ${{ inputs.hetzner_id }}
+ run: |
+
+ eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
+ brew install hcloud
+ hcloud server list
+
+ - name: "Kill runners"
+ if: ${{ github.repository_owner == 'Armbian' && inputs.action-type == 'enable' }}
+ env:
+ HCLOUD_TOKEN: ${{ inputs.hetzner_id }}
+ HOMEBREW_NO_AUTO_UPDATE: 1
+ HOMEBREW_CLEANUP_PERIODIC_FULL_DAYS: 3650
+ shell: bash
+ run: |
+
+ eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
+ machinenames=("Faerie" "November" "Raven" "Hammer" "Foxtrot" "Papa" "Chimera" "Panther")
+ machinename="${machinenames[${{ inputs.machine-id }}]}"
+ machinenameid=$(hcloud server list --output columns=id,name | grep ${machinename} | cut -d" " -f1 || true)
+ [[ -n "${machinenameid}" ]] && hcloud server delete "${machinenameid}" || true
+
+ - name: "Kill runners"
+ if: ${{ github.repository_owner == 'Armbian' && inputs.action-type == 'disable' }}
+ env:
+ HCLOUD_TOKEN: ${{ inputs.hetzner_id }}
+ HOMEBREW_NO_AUTO_UPDATE: 1
+ HOMEBREW_CLEANUP_PERIODIC_FULL_DAYS: 3650
+ shell: bash
+ run: |
+
+ eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
+ # we will set fixed number and fixed machine names
+ machinenames=("Faerie" "November" "Raven" "Hammer" "Foxtrot" "Papa" "Chimera" "Panther")
+ for machinename in "${machinenames[@]}"
+ do
+ machinenameid=$(hcloud server list --output columns=id,name | grep ${machinename} | cut -d" " -f1 || true)
+ [[ -n "${machinenameid}" ]] && hcloud server delete "${machinenameid}" || true
+ done
+
+ - name: "Deploy runners"
+ if: ${{ inputs.action-type == 'enable' }}
+ env:
+ HCLOUD_TOKEN: ${{ inputs.hetzner_id }}
+ GH_TOKEN: ${{ inputs.github_token }}
+ HOMEBREW_NO_AUTO_UPDATE: 1
+ HOMEBREW_CLEANUP_PERIODIC_FULL_DAYS: 3650
+ shell: bash
+ run: |
+
+ eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
+ machinenames=("Faerie" "November" "Raven" "Hammer" "Foxtrot" "Papa" "Chimera" "Panther")
+ machinename="${machinenames[${{ inputs.machine-id }}]}"
+ hcloud server create --name ${machinename} --image ubuntu-22.04 --type ${{ inputs.machine-type }} --ssh-key TORRENT
+
+ # make sure all are up
+ sleep 30
+
+ IP=$(hcloud server list --output columns=ipv4,name | grep ${machinename} | cut -d" " -f1)
+ ssh -o StrictHostKeyChecking=no root@${IP} "\
+ export STOP=${{ inputs.runners-count}} NAME=${machinename} GH_TOKEN=${{ env.GH_TOKEN }}; \
+ git clone https://github.com/armbian/scripts; cd scripts/generate-runners; ./deploy.sh"
+
+ - name: Remove runners
+ if: ${{ inputs.action-type == 'disable' }}
+ env:
+ GH_TOKEN: ${{ inputs.github_token }}
+ shell: bash
+ run: |
+
+ RUNNERS=$(gh api \
+ -H "Accept: application/vnd.github+json" \
+ -H "X-GitHub-Api-Version: 2022-11-28" \
+ "/repos/armbian/os/actions/runners?per_page=1000" | \
+ jq -r '.runners[] | select(.labels[].name=="temp")' | jq '.id')
+
+ while IFS= read -r id; do
+ gh api --silent \
+ --method DELETE \
+ -H "Accept: application/vnd.github+json" \
+ -H "X-GitHub-Api-Version: 2022-11-28" \
+ /repos/armbian/os/actions/runners/${id}
+ done <<< $RUNNERS
\ No newline at end of file
diff --git a/hetzner_off/action.yml b/hetzner_off/action.yml
deleted file mode 100644
index 187eeb5..0000000
--- a/hetzner_off/action.yml
+++ /dev/null
@@ -1,92 +0,0 @@
-name: "Enable Hetzner VMs"
-author: "Igor Pecovnik"
-inputs:
- machine-type:
- required: true
- machine-count:
- required: true
- runners-count:
- required: true
- key:
- required: true
- known_hosts:
- required: true
- hetzner_id:
- required: true
- github_token:
- required: true
-
-runs:
- using: "composite"
- steps:
-
- - name: Install SSH key for storage
- uses: shimataro/ssh-key-action@v2
- with:
- key: ${{ inputs.key }}
- known_hosts: ${{ inputs.known_hosts }}
- if_key_exists: replace
-
- - name: Install Homebrew
- shell: bash
- run: |
-
- /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- (echo; echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"') >> ${HOME}/.bash_profile
- eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
- brew install hcloud
-
- - name: Install Homebrew
- env:
- HCLOUD_TOKEN: ${{ inputs.hetzner_id }}
- GH_TOKEN: ${{ inputs.github_token }}
- shell: bash
- run: |
-
- # we will use fixed machine names.
- machinenames=("Faerie" "November" "Raven" "Hammer" "Foxtrot" "Papa" "Chimera" "Panther")
- for machinename in "${machinenames[@]}"
- do
- eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
- hcloud server delete $(hcloud server list --output columns=id,name | grep ${machinename} | cut -d" " -f1)
- i=$(( i + 1 ))
- [[ $i == ${{ inputs.machine-count }} ]] && break
- done
-
- - name: Remove runners
- env:
- GH_TOKEN: ${{ inputs.github_token }}
- shell: bash
- run: |
-
- # for some reason last added doesn't show up
- #RUNNERS=$(gh api \
- #-H "Accept: application/vnd.github+json" \
- #-H "X-GitHub-Api-Version: 2022-11-28" \
- #"/orgs/${{ github.repository_owner }}/actions/runners?per_page=1000" | \
- #jq -r '.runners[] | select(.labels[].name=="temp")' | jq '.id')
-
- # get all runners that have label "temp"
- RUNNERS=$(gh api \
- -H "Accept: application/vnd.github+json" \
- -H "X-GitHub-Api-Version: 2022-11-28" \
- "/repos/${{ github.repository_owner }}/os/actions/runners?per_page=1000" | \
- jq -r '.runners[] | select(.labels[].name=="temp")' | jq '.id')
-
- # remove them
- # while IFS= read -r id; do
- #gh api \
- #--method DELETE \
- #-H "Accept: application/vnd.github+json" \
- #-H "X-GitHub-Api-Version: 2022-11-28" \
- #/orgs/${{ github.repository_owner }}/actions/runners/${id}
- #done <<< $RUNNERS
-
- # remove them
- while IFS= read -r id; do
- gh api \
- --method DELETE \
- -H "Accept: application/vnd.github+json" \
- -H "X-GitHub-Api-Version: 2022-11-28" \
- /repos/${{ github.repository_owner }}/os/actions/runners/${id}
- done <<< $RUNNERS
\ No newline at end of file
diff --git a/hetzner_on/action.yml b/hetzner_on/action.yml
deleted file mode 100644
index 1ffb870..0000000
--- a/hetzner_on/action.yml
+++ /dev/null
@@ -1,71 +0,0 @@
-name: "Enable Hetzner VMs"
-author: "Igor Pecovnik"
-inputs:
- machine-type:
- required: true
- machine-count:
- required: true
- runners-count:
- required: true
- key:
- required: true
- known_hosts:
- required: true
- hetzner_id:
- required: true
- github_token:
- required: true
-
-runs:
- using: "composite"
- steps:
-
- - name: Install SSH key for storage
- uses: shimataro/ssh-key-action@v2
- with:
- key: ${{ inputs.key }}
- known_hosts: ${{ inputs.known_hosts }}
- if_key_exists: replace
-
- - name: Install Homebrew
- shell: bash
- run: |
-
- /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- (echo; echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"') >> ${HOME}/.bash_profile
- eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
- brew install hcloud
-
- - name: Install Homebrew
- env:
- HCLOUD_TOKEN: ${{ inputs.hetzner_id }}
- GH_TOKEN: ${{ inputs.github_token }}
- shell: bash
- run: |
-
- COMMAND="git clone https://github.com/armbian/scripts; cd scripts/generate-runners; ./deploy.sh"
-
- eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
-
- # we will use fixed machine names.
- machinenames=("Faerie" "November" "Raven" "Hammer" "Foxtrot" "Papa" "Chimera" "Panther")
- for machinename in "${machinenames[@]}"
- do
- hcloud server delete $(hcloud server list --output columns=id,name | grep ${machinename} | cut -d" " -f1) || true
- hcloud server create --name ${machinename} --image ubuntu-22.04 --type ${{ inputs.machine-type }} --ssh-key TORRENT
- i=$(( i + 1 ))
- [[ $i == ${{ inputs.machine-count }} ]] && break
- done
-
- # make sure all are up
- sleep 20
-
- i=0
- for machinename in "${machinenames[@]}"
- do
- IP=$(hcloud server list --output columns=ipv4,name | grep ${machinename} | cut -d" " -f1)
- ssh-keygen -f "$HOME/.ssh/known_hosts" -R "${IP}" || true
- ssh -o StrictHostKeyChecking=no root@${IP} "export STOP=${{ inputs.runners-count}} NAME=${machinename} GH_TOKEN=${{ env.GH_TOKEN }}; $COMMAND"
- i=$(( i + 1 ))
- [[ $i == ${{ inputs.machine-count }} ]] && break
- done
\ No newline at end of file