nix/.forgejo/workflows/update-flake-lock.yml

117 lines
3.8 KiB
YAML
Raw Normal View History

2023-10-03 14:49:47 +02:00
name: update-flake-lock
run-name: ${{ github.actor }} - update-flake-lock
2023-11-30 07:01:52 +01:00
on:
2024-04-13 03:32:37 +02:00
schedule:
2024-05-21 10:43:59 +02:00
- cron: '0 0 * * 0'
# “At 00:00 Sunday."
2024-02-05 05:30:33 +01:00
2023-10-02 12:08:16 +02:00
jobs:
2023-10-03 14:49:47 +02:00
update-flake-lock:
2024-02-05 05:30:33 +01:00
runs-on: ubuntu
2023-10-03 13:47:28 +02:00
container:
2024-06-30 01:22:03 +02:00
image: ubuntu:24.04
2024-06-30 03:01:17 +02:00
options: --mount type=bind,src=/dev/net/tun,dst=/dev/net/tun --privileged
2023-10-02 12:08:16 +02:00
steps:
2024-06-30 03:01:17 +02:00
- name: "Runner: Info"
run: |
set -x
pwd
ls -lah
id
uname -a
hostname
cat /etc/os-release
whoami
id
cat /etc/resolv.conf
- name: "Setup: Runner"
2023-10-03 13:53:46 +02:00
run: |
2024-02-05 05:30:33 +01:00
apt update -y
2024-06-30 03:01:17 +02:00
apt install git nodejs nix-bin sudo curl -y
2023-10-04 02:51:24 +02:00
git config --global user.email "${{github.actor}}"
2024-04-24 04:17:10 +02:00
git config --global user.name "Forgejo Runner"
2024-04-24 02:30:25 +02:00
echo "100.64.0.14 gotify.sysctl.io" >> /etc/hosts
2024-06-30 03:01:17 +02:00
- name: "Setup: Tailscale Repo"
2023-10-03 04:47:57 +02:00
run: |
2024-06-30 03:01:17 +02: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
- name: "Setup: SSH"
2023-10-03 12:42:17 +02:00
run: |
2024-06-30 03:01:17 +02:00
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
chmod 600 /root/.ssh/id_ed25519
chmod 644 /root/.ssh/id_ed25519.pub
- name: "Setup: Headscale Network"
2024-06-18 03:21:52 +02:00
run: |
2024-06-30 03:01:17 +02:00
echo "tailscaled --cleanup"
sudo tailscaled --cleanup
echo ""
echo "tailscaled --state=mem 2> ~/tailscaled.log &"
sudo tailscaled --state=mem: 2> ~/tailscaled.log &
echo ""
echo "tailscale up"
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-06-30 03:22:39 +02:00
- name: "SSH and Update / Check"
2024-06-30 03:01:17 +02:00
run: |
ssh -q -A -o StrictHostKeyChecking=no albert@framework-server \
"
set -x
eval (ssh-agent -c)
ssh-add
env | grep SSH
cd /etc/nixos/git
git pull
nix flake update
nix flake check
"
2024-06-18 03:21:52 +02:00
- if: success()
2024-06-30 03:01:17 +02:00
name: "Sucess: Git Commit & Push"
run: |
ssh -q -A -o StrictHostKeyChecking=no albert@framework-server \
"
set -x
eval (ssh-agent -c)
ssh-add
env | grep SSH
cd /etc/nixos/git
2024-07-07 04:11:15 +02:00
git -c commit.gpgsign=false commit -am '[ACTIONS] Flake Update (`date +%Y-%m-%d`)' \
&& git push
2024-06-30 03:01:17 +02:00
"
2023-10-04 02:42:45 +02:00
- if: success()
2023-12-20 14:21:52 +01:00
uses: https://git.sysctl.io/actions/gotify-action@master
with:
gotify_api_base: '${{ secrets.GOTIFY_URL }}'
gotify_app_token: '${{ secrets.GOTIFY_TOKEN }}'
2023-12-20 14:40:58 +01:00
notification_title: '[ ${{ github.repository }}: ${{ github.workflow }} ] NixOS Flake Updated'
2023-12-20 14:21:52 +01:00
notification_message: 'Build completed successfully.'
- if: failure()
uses: https://git.sysctl.io/actions/gotify-action@master
with:
gotify_api_base: '${{ secrets.GOTIFY_URL }}'
gotify_app_token: '${{ secrets.GOTIFY_TOKEN }}'
2023-12-20 14:40:58 +01:00
notification_title: '[ ${{ github.repository }}: ${{ github.workflow }} ] Build Failed'
2023-12-20 14:23:18 +01:00
notification_message: 'Your build has failed. Check Forgejo.'
2024-02-23 03:05:07 +01:00
name: "Send Notification"