2024-11-03 12:47:02 +01:00
|
|
|
# yamllint disable rule:line-length rule:truthy
|
|
|
|
---
|
2024-12-05 00:38:19 +01:00
|
|
|
name: Manual - deploy-rs
|
2023-12-25 03:30:44 +01:00
|
|
|
run-name: ${{ github.actor }} - deploy-rs
|
|
|
|
on:
|
2024-11-03 08:54:09 +01:00
|
|
|
workflow_dispatch:
|
|
|
|
inputs:
|
2023-12-25 08:48:57 +01:00
|
|
|
|
2023-12-25 03:30:44 +01:00
|
|
|
jobs:
|
2023-12-25 03:32:41 +01:00
|
|
|
deploy-rs:
|
2024-04-05 01:26:10 +02:00
|
|
|
runs-on: ubuntu
|
2024-09-03 14:40:50 +02:00
|
|
|
container:
|
2024-06-30 03:01:17 +02:00
|
|
|
image: ubuntu:24.04
|
2023-12-25 05:44:31 +01:00
|
|
|
options: --mount type=bind,src=/dev/net/tun,dst=/dev/net/tun --privileged
|
2023-12-25 03:30:44 +01:00
|
|
|
steps:
|
2024-11-03 12:47:02 +01:00
|
|
|
- name: "Setup: Runner"
|
2024-11-07 05:06:11 +01:00
|
|
|
run: |
|
2024-11-03 13:06:10 +01:00
|
|
|
set -x
|
2024-11-03 12:47:02 +01:00
|
|
|
apt update -y
|
|
|
|
apt install git nodejs nix-bin sudo curl -y
|
2024-11-07 03:03:19 +01:00
|
|
|
git config --global user.email ${{github.actor}}
|
|
|
|
git config --global user.name "Forgejo Runner"
|
2024-11-03 12:47:02 +01:00
|
|
|
echo "100.64.0.13 gotify.sysctl.io" >> /etc/hosts
|
2024-04-13 16:33:14 +02:00
|
|
|
|
2024-11-03 12:47:02 +01:00
|
|
|
- name: "Setup: Tailscale Repo"
|
|
|
|
run: |
|
2024-11-07 03:02:01 +01:00
|
|
|
set -x
|
2024-11-03 12:47:02 +01:00
|
|
|
mkdir -p --mode=0755 /usr/share/keyrings
|
|
|
|
curl -fsSL https://pkgs.tailscale.com/stable/ubuntu/lunar.noarmor.gpg | sudo tee /usr/share/keyrings/tailscale-archive-keyring.gpg >/dev/null
|
|
|
|
curl -fsSL https://pkgs.tailscale.com/stable/ubuntu/lunar.tailscale-keyring.list | sudo tee /etc/apt/sources.list.d/tailscale.list
|
|
|
|
apt update -y
|
|
|
|
apt install tailscale -y
|
2024-09-03 14:40:50 +02:00
|
|
|
|
2024-11-03 12:47:02 +01:00
|
|
|
- name: "Setup: SSH"
|
|
|
|
run: |
|
|
|
|
rm -rf /root/.ssh
|
|
|
|
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
|
2024-12-05 22:43:06 +01:00
|
|
|
chmod 600 /root/.ssh/id_ed25519
|
|
|
|
chmod 644 /root/.ssh/id_ed25519.pub
|
2024-12-05 00:38:19 +01:00
|
|
|
echo "Result: $?"
|
2023-12-25 05:44:31 +01:00
|
|
|
|
2024-12-05 23:28:42 +01:00
|
|
|
- name: "Setup: Headscale Network"
|
2024-11-03 12:47:02 +01:00
|
|
|
run: |
|
2024-11-07 03:02:01 +01:00
|
|
|
set -x
|
2024-11-03 12:47:02 +01:00
|
|
|
sudo tailscaled --cleanup
|
|
|
|
sudo tailscaled --state=mem: 2> ~/tailscaled.log &
|
|
|
|
sudo tailscale up \
|
|
|
|
--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"
|
|
|
|
sudo tailscale status
|
|
|
|
sudo tailscale netcheck
|
2024-12-05 00:38:19 +01:00
|
|
|
echo "Result: $?"
|
2023-12-25 03:30:44 +01:00
|
|
|
|
2024-11-03 12:47:02 +01:00
|
|
|
- name: "nixos-version (Pre)"
|
|
|
|
run: |
|
2024-12-05 00:38:19 +01:00
|
|
|
set -x
|
2024-12-05 22:20:48 +01:00
|
|
|
ssh -A -o StrictHostKeyChecking=no albert@warsaw-ovh-01 \
|
2024-11-03 12:47:02 +01:00
|
|
|
"
|
|
|
|
nixos-version
|
|
|
|
"
|
2024-12-05 00:38:19 +01:00
|
|
|
echo "Result: $?"
|
2024-01-16 00:43:14 +01:00
|
|
|
|
2024-11-03 12:47:02 +01:00
|
|
|
- name: "SSH and Deploy"
|
|
|
|
run: |
|
2024-12-05 00:38:19 +01:00
|
|
|
set -x
|
2024-11-03 12:47:02 +01:00
|
|
|
ssh -q -A -o StrictHostKeyChecking=no albert@warsaw-ovh-01 \
|
|
|
|
"
|
|
|
|
set -x
|
|
|
|
eval (ssh-agent -c)
|
|
|
|
ssh-add
|
|
|
|
env | grep SSH
|
|
|
|
cd /etc/nixos/git
|
|
|
|
git pull
|
|
|
|
ssh -qA osaka-linode-01 'sudo systemctl restart podman-derp'
|
|
|
|
ssh -qA frankfurt-linode-01 'sudo systemctl restart podman-derp'
|
|
|
|
ssh -qA milan-linode-01 'sudo systemctl restart podman-derp'
|
|
|
|
ssh -qA warsaw-ovh-01 'sudo systemctl restart container@rdesktop'
|
|
|
|
sleep 30
|
|
|
|
deploy -sd
|
2024-11-11 18:57:28 +01:00
|
|
|
deploy -sd
|
2024-11-03 12:47:02 +01:00
|
|
|
"
|
2024-12-05 00:38:19 +01:00
|
|
|
echo "Result: $?"
|
2023-12-25 03:30:44 +01:00
|
|
|
|
2024-11-03 12:47:02 +01:00
|
|
|
- name: "nixos-version (Post)"
|
|
|
|
run: |
|
2024-12-05 00:38:19 +01:00
|
|
|
set -x
|
2024-11-03 12:47:02 +01:00
|
|
|
ssh -q -A -o StrictHostKeyChecking=no albert@warsaw-ovh-01 \
|
|
|
|
"
|
|
|
|
nixos-version
|
|
|
|
"
|
|
|
|
tailscale down
|
2024-01-16 00:43:14 +01:00
|
|
|
|
2024-11-03 12:47:02 +01:00
|
|
|
- if: success()
|
|
|
|
uses: https://git.sysctl.io/actions/gotify-action@master
|
|
|
|
with:
|
|
|
|
gotify_api_base: '${{ secrets.GOTIFY_URL }}'
|
|
|
|
gotify_app_token: '${{ secrets.GOTIFY_TOKEN }}'
|
|
|
|
notification_title: '[ ${{ github.repository }}: ${{ github.workflow }} ] NixOS Deployed'
|
|
|
|
notification_message: 'Deployment completed successfully.'
|
|
|
|
name: "Send Notification - Success"
|
|
|
|
- if: failure()
|
|
|
|
uses: https://git.sysctl.io/actions/gotify-action@master
|
|
|
|
with:
|
|
|
|
gotify_api_base: '${{ secrets.GOTIFY_URL }}'
|
|
|
|
gotify_app_token: '${{ secrets.GOTIFY_TOKEN }}'
|
|
|
|
notification_title: '[ ${{ github.repository }}: ${{ github.workflow }} ] Deployment Failed'
|
|
|
|
notification_message: 'Your deployment has failed. Check Forgejo.'
|
|
|
|
name: "Send Notification - Failure"
|