nix/.forgejo/workflows/ssh-test.yml

87 lines
2.5 KiB
YAML
Raw Normal View History

2023-12-08 12:04:16 +01:00
name: ssh-test
run-name: ${{ github.actor }} - ssh-test
2023-12-08 12:04:24 +01:00
on:
push:
branches:
- main
2023-12-08 12:04:16 +01:00
jobs:
ssh-test:
runs-on: docker
container:
image: alpine:edge
2023-12-08 14:09:45 +01:00
options: --mount type=bind,src=/dev/net/tun,dst=/dev/net/tun --privileged
2023-12-08 12:04:16 +01:00
steps:
2023-12-08 13:50:35 +01:00
- name: "Runner: Info"
run: |
2023-12-08 13:51:34 +01:00
echo "============= pwd"
2023-12-08 13:50:35 +01:00
pwd
2023-12-08 13:51:34 +01:00
echo "============= ls -lah"
2023-12-08 13:50:35 +01:00
ls -lah
2023-12-08 13:51:34 +01:00
echo '============= id'
2023-12-08 13:50:35 +01:00
id
2023-12-08 13:51:34 +01:00
echo "============= uname -a"
2023-12-08 13:50:35 +01:00
uname -a
2023-12-08 13:51:34 +01:00
echo "============= hostname"
2023-12-08 13:50:35 +01:00
hostname
2023-12-08 13:51:34 +01:00
echo "============= /etc/os-release"
2023-12-08 13:50:35 +01:00
cat /etc/os-release
2023-12-08 13:51:34 +01:00
echo "============= whoami"
2023-12-08 13:50:35 +01:00
whoami
2023-12-08 13:51:34 +01:00
id
echo "============= cat /etc/resolv.conf"
2023-12-08 13:50:35 +01:00
cat /etc/resolv.conf
2023-12-08 12:04:16 +01:00
- name: "Setup: Runner"
run: |
apk update
2023-12-08 14:00:44 +01:00
apk add git nodejs nix openssh-client qemu tailscale sudo --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing/
2023-12-08 12:41:38 +01:00
- name: "Setup: SSH"
run: |
mkdir /root/.ssh
echo "${{ secrets.SSH_PUBLIC_KEY }}" > /root/.ssh/id_ed25519.pub
echo "${{ secrets.SSH_PRIVATE_KEY }}" > /root/.ssh/id_ed25519
chmod 700 /root/.ssh
chmod 600 /root/.ssh/id_ed25519
chmod 644 /root/.ssh/id_ed25519.pub
2023-12-08 13:52:01 +01:00
echo "Public Key: "
cat /root/.ssh/id_ed25519.pub
2023-12-08 12:41:38 +01:00
- name: "Setup: Headscale"
run: |
2023-12-08 13:16:13 +01:00
echo "tailscaled --cleanup"
2023-12-08 14:00:13 +01:00
sudo tailscaled --cleanup
2023-12-08 13:16:13 +01:00
echo ""
2023-12-08 13:32:18 +01:00
echo "tailscaled --state=mem 2> ~/tailscaled.log &"
2023-12-08 14:00:13 +01:00
sudo tailscaled --state=mem: 2> ~/tailscaled.log &
2023-12-08 13:16:13 +01:00
echo ""
echo "tailscale up"
2023-12-08 14:00:13 +01:00
sudo tailscale up \
2023-12-08 13:11:42 +01:00
--login-server=https://headscale.sysctl.io \
--accept-routes \
--accept-dns \
--authkey ${{ secrets.TAILSCALE_KEY }} \
--hostname forgejo-runner \
--advertise-tags "tag:forgejo,tag:container,tag:ephemeral"
2023-12-08 14:00:13 +01:00
sudo tailscale status
sudo tailscale netcheck
2023-12-08 12:41:38 +01:00
2023-12-08 12:04:16 +01:00
- uses: actions/checkout@v3
- name: "Directory Structure"
run: |
ls ${{ github.workspace }}/*
2023-12-08 12:41:38 +01:00
2023-12-08 12:04:16 +01:00
- name: "Nix Version"
run: |
nix --version
2023-12-08 14:21:38 +01:00
- name: "Nix build - nixos-vm-01"
run: |
echo "Running Nix Build"
nix --extra-experimental-features "nix-command flakes" \
build --flake /etc/nixos/git#nixos-vm-01 --target-host nixos-vm-01
2023-12-08 12:04:16 +01:00
- if: always()
run: rm -rf /.cache
- if: always()
run: rm -rf ${{ github.worksspace }}