Update workflows

This commit is contained in:
albert 2024-12-05 00:38:19 +01:00
parent 98dbb785e4
commit 16e9b4d029
Signed by: albert
GPG key ID: 3895DD267CA11BA9
2 changed files with 8 additions and 110 deletions

View file

@ -1,109 +0,0 @@
# yamllint disable rule:line-length rule:truthy
---
name: Cron - deploy-rs
run-name: ${{ github.actor }} - deploy-rs
on:
schedule:
- cron: '0 2 * * 0'
# “At 02:00 Sunday."
jobs:
deploy-rs:
runs-on: ubuntu
container:
image: ubuntu:24.04
options: --mount type=bind,src=/dev/net/tun,dst=/dev/net/tun --privileged
steps:
- name: "Setup: Runner"
run: |
set -x
echo 'Why is nothing being output here'
apt update -y
apt install git nodejs nix-bin sudo curl -y
git config --global user.email ${{github.actor}}
git config --global user.name "Forgejo Runner"
echo "100.64.0.13 gotify.sysctl.io" >> /etc/hosts
- name: "Setup: Tailscale Repo"
run: |
set -x
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
- name: "Setup: SSH"
run: |
set -x
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
- name: "Setup: Headscale Network"
run: |
set -x
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
- name: "nixos-version (Pre)"
run: |
ssh -q -A -o StrictHostKeyChecking=no albert@warsaw-ovh-01 \
"
nixos-version
"
- name: "SSH and Deploy"
run: |
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
deploy -sd
"
- name: "nixos-version (Post)"
run: |
ssh -q -A -o StrictHostKeyChecking=no albert@warsaw-ovh-01 \
"
nixos-version
"
tailscale down
- 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"

View file

@ -1,6 +1,6 @@
# yamllint disable rule:line-length rule:truthy # yamllint disable rule:line-length rule:truthy
--- ---
name: Cron - deploy-rs name: Manual - deploy-rs
run-name: ${{ github.actor }} - deploy-rs run-name: ${{ github.actor }} - deploy-rs
on: on:
workflow_dispatch: workflow_dispatch:
@ -40,6 +40,7 @@ jobs:
echo "${{ secrets.SSH_PUBLIC_KEY }}" > /root/.ssh/id_ed25519.pub echo "${{ secrets.SSH_PUBLIC_KEY }}" > /root/.ssh/id_ed25519.pub
echo "${{ secrets.SSH_PRIVATE_KEY }}" > /root/.ssh/id_ed25519 echo "${{ secrets.SSH_PRIVATE_KEY }}" > /root/.ssh/id_ed25519
chmod 700 /root/.ssh chmod 700 /root/.ssh
echo "Result: $?"
- name: "Setup: Headscale Network" - name: "Setup: Headscale Network"
run: | run: |
@ -55,16 +56,20 @@ jobs:
--advertise-tags "tag:forgejo,tag:container,tag:ephemeral" --advertise-tags "tag:forgejo,tag:container,tag:ephemeral"
sudo tailscale status sudo tailscale status
sudo tailscale netcheck sudo tailscale netcheck
echo "Result: $?"
- name: "nixos-version (Pre)" - name: "nixos-version (Pre)"
run: | run: |
set -x
ssh -q -A -o StrictHostKeyChecking=no albert@warsaw-ovh-01 \ ssh -q -A -o StrictHostKeyChecking=no albert@warsaw-ovh-01 \
" "
nixos-version nixos-version
" "
echo "Result: $?"
- name: "SSH and Deploy" - name: "SSH and Deploy"
run: | run: |
set -x
ssh -q -A -o StrictHostKeyChecking=no albert@warsaw-ovh-01 \ ssh -q -A -o StrictHostKeyChecking=no albert@warsaw-ovh-01 \
" "
set -x set -x
@ -81,9 +86,11 @@ jobs:
deploy -sd deploy -sd
deploy -sd deploy -sd
" "
echo "Result: $?"
- name: "nixos-version (Post)" - name: "nixos-version (Post)"
run: | run: |
set -x
ssh -q -A -o StrictHostKeyChecking=no albert@warsaw-ovh-01 \ ssh -q -A -o StrictHostKeyChecking=no albert@warsaw-ovh-01 \
" "
nixos-version nixos-version