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

Start selfhosted runner using ssh #27

Merged
merged 11 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
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
65 changes: 47 additions & 18 deletions .ci/template/sh-build-iso.yml.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,30 @@ on:

jobs:
vm-start:
if: always()
runs-on: ubuntu-latest

steps:
- name: Start virtual machine
- name: Save ssh configuration
run: |
# FIXME
exit 0
# Create ssh directory
mkdir ~/.ssh
{% raw %}
# Save ssh config
echo "${{ secrets.SSH_CONFIG }}" | base64 -d > ~/.ssh/config

# Save ssh known hosts
echo "${{ secrets.SSH_KNOWN_HOSTS }}" | base64 -d > ~/.ssh/known_hosts

# Save ssh private key
echo "${{ secrets.SSH_PRIVATE_KEY }}" | base64 -d > /tmp/private.key
{% endraw %}
# Fix permissions for private key
chmod 600 /tmp/private.key

- name: Start Github Actions Runner VM
run: |
ssh runner "virsh start GithubActions"

build:
needs: vm-start
Expand Down Expand Up @@ -73,24 +90,36 @@ jobs:
name: archiso-output
path: out/

vm-shutdown:
if: "!cancelled()"
vm-stop:
if: always()
needs: build
runs-on: self-hosted

steps:
- name: Stop virtual machine
run: |
# Shutdown in 1 minute
sudo shutdown 1

vm-shutdown-wait:
if: "!cancelled()"
needs: vm-shutdown
runs-on: ubuntu-latest

steps:
- name: Wait until virtual machine is stopped
- name: Save ssh configuration
run: |
# Create ssh directory
mkdir ~/.ssh
{% raw %}
# Save ssh config
echo "${{ secrets.SSH_CONFIG }}" | base64 -d > ~/.ssh/config

# Save ssh known hosts
echo "${{ secrets.SSH_KNOWN_HOSTS }}" | base64 -d > ~/.ssh/known_hosts

# Save ssh private key
echo "${{ secrets.SSH_PRIVATE_KEY }}" | base64 -d > /tmp/private.key
{% endraw %}
# Fix permissions for private key
chmod 600 /tmp/private.key

- name: Stop Github Actions Runner VM
run: |
# Wait for 2 minutes
# Invoke regular shutdown
ssh runner "virsh shutdown GithubActions"

# Wait 2 minutes
sleep 120

# Force terminate if needed
ssh runner "virsh destroy GithubActions" || true
63 changes: 46 additions & 17 deletions .github/workflows/sh-build-iso-rocm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,30 @@ on:

jobs:
vm-start:
if: always()
runs-on: ubuntu-latest

steps:
- name: Start virtual machine
- name: Save ssh configuration
run: |
# FIXME
exit 0
# Create ssh directory
mkdir ~/.ssh

# Save ssh config
echo "${{ secrets.SSH_CONFIG }}" | base64 -d > ~/.ssh/config

# Save ssh known hosts
echo "${{ secrets.SSH_KNOWN_HOSTS }}" | base64 -d > ~/.ssh/known_hosts

# Save ssh private key
echo "${{ secrets.SSH_PRIVATE_KEY }}" | base64 -d > /tmp/private.key

# Fix permissions for private key
chmod 600 /tmp/private.key

- name: Start Github Actions Runner VM
run: |
ssh runner "virsh start GithubActions"

build:
needs: vm-start
Expand Down Expand Up @@ -71,24 +88,36 @@ jobs:
name: archiso-output
path: out/

vm-shutdown:
if: "!cancelled()"
vm-stop:
if: always()
needs: build
runs-on: self-hosted
runs-on: ubuntu-latest

steps:
- name: Stop virtual machine
- name: Save ssh configuration
run: |
# Shutdown in 1 minute
sudo shutdown 1
# Create ssh directory
mkdir ~/.ssh

vm-shutdown-wait:
if: "!cancelled()"
needs: vm-shutdown
runs-on: ubuntu-latest
# Save ssh config
echo "${{ secrets.SSH_CONFIG }}" | base64 -d > ~/.ssh/config

steps:
- name: Wait until virtual machine is stopped
# Save ssh known hosts
echo "${{ secrets.SSH_KNOWN_HOSTS }}" | base64 -d > ~/.ssh/known_hosts

# Save ssh private key
echo "${{ secrets.SSH_PRIVATE_KEY }}" | base64 -d > /tmp/private.key

# Fix permissions for private key
chmod 600 /tmp/private.key

- name: Stop Github Actions Runner VM
run: |
# Wait for 2 minutes
sleep 120
# Invoke regular shutdown
ssh runner "virsh shutdown GithubActions"

# Wait 2 minutes
sleep 120

# Force terminate if needed
ssh runner "virsh destroy GithubActions" || true