2022-06-23 12:23:54 +00:00
|
|
|
---
|
|
|
|
kind: pipeline
|
|
|
|
type: docker
|
|
|
|
name: update-flake
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Update flake
|
|
|
|
image: nixos/nix
|
|
|
|
commands:
|
|
|
|
- echo "substituters = https://cache.nixos.org/ https://f000.backblazeb2.com/file/cache-chir-rs/" >> /etc/nix/nix.conf
|
|
|
|
- echo "trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= nixcache:8KKuGz95Pk4UJ5W/Ni+pN+v+LDTkMMFV4yrGmAYgkDg= hydra.nixos.org-1:CNHJZBh9K4tP3EKF6FkkgeVYsS3ohTl+oS0Qa8bezVs=" >> /etc/nix/nix.conf
|
2022-07-04 07:09:32 +00:00
|
|
|
- echo "experimental-features = nix-command flakes ca-derivations" >> /etc/nix/nix.conf
|
2022-06-23 12:23:54 +00:00
|
|
|
- |
|
|
|
|
for job in nixos-8gb-fsn1-1 nutty-noon thinkrac installer nas; do
|
|
|
|
nix show-derivation -r ".#hydraJobs.$job.x86_64-linux" > ../old-$job.json
|
|
|
|
done
|
|
|
|
|
|
|
|
nix flake update
|
|
|
|
|
|
|
|
for job in nixos-8gb-fsn1-1 nutty-noon thinkrac installer nas; do
|
|
|
|
nix show-derivation -r ".#hydraJobs.$job.x86_64-linux" > ../new-$job.json
|
|
|
|
|
2022-06-24 09:09:38 +00:00
|
|
|
nix-shell -p python3 --run "python scripts/diff-drvs.py ../old-$job.json ../new-$job.json" > ../report-$job.txt
|
2022-06-24 09:43:42 +00:00
|
|
|
cat ../report-$job.txt >> ../full-report.txt
|
2022-06-23 12:23:54 +00:00
|
|
|
done
|
|
|
|
if [ -s ../full-report.txt ]; then
|
|
|
|
echo "Automatic flake.lock update" > ../pr-message.txt
|
|
|
|
echo "" >> ../pr-message.txt
|
|
|
|
for job in nixos-8gb-fsn1-1 nutty-noon thinkrac installer nas; do
|
|
|
|
echo "## Changes for $job:" >> ../pr-message.txt
|
|
|
|
echo '```' >> ../pr-message.txt
|
2022-06-24 10:41:13 +00:00
|
|
|
cat ../report-$job.txt >> ../pr-message.txt
|
2022-06-23 12:23:54 +00:00
|
|
|
echo '```' >> ../pr-message.txt
|
|
|
|
done
|
|
|
|
else
|
|
|
|
touch ../pr-message.txt
|
|
|
|
fi
|
2022-06-25 07:30:34 +00:00
|
|
|
mv ../pr-message.txt .
|
2022-06-23 12:23:54 +00:00
|
|
|
- name: Push git
|
2022-06-24 08:34:59 +00:00
|
|
|
image: alpine:latest
|
|
|
|
commands:
|
|
|
|
- apk add git openssh git-lfs
|
|
|
|
- mkdir ~/.ssh
|
|
|
|
- echo "$SSH_KEY" > ~/.ssh/id_ed25519
|
|
|
|
- chmod 600 ~/.ssh/id_ed25519
|
|
|
|
- echo "git.chir.rs ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICQ77jA9S5qXDFGPLZRsC++AtxiXXeF8gVbkLlglx0GQ" > ~/.ssh/known_hosts
|
|
|
|
- echo "git.chir.rs ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDY0pZzNTAqaVqqfC31gYFixFs5KySv0UqvlDEAzEXJMB/pBWkE5GAd5Ik1NxD4QiAVWc2UARdmJEBbYf8mk5JiAv6fjsodJdJVRau4Ax7FtIfbxdFyzBgFery/KUnNIr6cmAWU2Af8JhzrnpEbhe5U3LftYnkdE1lI+iVqaQRARp0qikdzoAl3uMUhbdTxp1/6rtfN6bP2XZCsUx3t3W5ZG1QTQz8l7nrbXZX1TT3pZ2vcUANcMtOxEAwO6lbL210GX63C8XEoE7+4lLxRrSiaq3SkVlG07VspozKEtrrcsqCRNLebiaapmNWVoEq9Wd9VGAEjja5efyU6/HUlRogAOo1WP73UwoQLv5LTFH+ECoHhKS14xfPeXeVG8dbYyh5+CnmiVe43dH1qZw+ceYuYel31f47cAgScbxFvNkct0spK9m9mivnoUmYcxwTc+VbFbmnJvSuZw3a+OEYn9biitP/tTkYFiLZVdPZTxDkvd1oOyuVH9d4RMXbVgNS92/lr2iKFZkyhWMJ61hFMc2tupwmkp5Us5ce42XA0zC/aVY3vYoih/c5Ib0eZF1AEJdB6Bt5dWqITVsB3mip3Jn/mqVBIPTGXT6+FnGSEuL68Dj2yKBD7kj8YO/1SWpkVMy+bfoLXY/usgcaLCxpUu8dDrdrcKExLigCVbi3rdRmg7w==" >> ~/.ssh/known_hosts
|
2022-06-24 12:41:45 +00:00
|
|
|
- git remote set-url origin gitea@git.chir.rs:darkkirb/nixos-config.git
|
2022-06-24 08:34:59 +00:00
|
|
|
- git config --global 'user.email' 'gitea-bot@chir.rs'
|
|
|
|
- git config --global 'user.name' 'Gitea Bot'
|
2022-06-25 07:30:34 +00:00
|
|
|
- git add flake.lock
|
|
|
|
- git commit -m "Update flake"
|
2022-06-24 08:34:59 +00:00
|
|
|
- git push --force origin main:update-flake
|
2022-06-24 11:53:15 +00:00
|
|
|
environment:
|
|
|
|
SSH_KEY:
|
|
|
|
from_secret: SSH_KEY
|
2022-06-23 12:23:54 +00:00
|
|
|
- name: Create pull request
|
|
|
|
image: alpine:latest
|
|
|
|
commands:
|
2022-07-04 07:09:32 +00:00
|
|
|
- mv pr-message.txt ..
|
2022-06-23 12:23:54 +00:00
|
|
|
- apk add jq curl
|
2022-06-23 12:25:48 +00:00
|
|
|
- |
|
2022-06-24 12:39:40 +00:00
|
|
|
echo '{ "assignee": "DarkKirb", "base": "main", "head": "update-flake", "title": "Update flake" }' | jq '.body = $body' --arg body "$(cat ../pr-message.txt)" | curl -XPOST 'https://git.chir.rs/api/v1/repos/DarkKirb/nixos-config/pulls' -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer $AUTHORISATION" --data-binary @-
|
2022-06-23 12:23:54 +00:00
|
|
|
environment:
|
|
|
|
AUTHORISATION:
|
|
|
|
from_secret: GITEA_KEY
|
2022-07-04 07:09:32 +00:00
|
|
|
#trigger:
|
|
|
|
# event:
|
|
|
|
# - cron
|
|
|
|
# cron:
|
|
|
|
# - updater
|
2022-06-23 12:23:54 +00:00
|
|
|
trigger:
|
|
|
|
event:
|
2022-07-04 07:09:32 +00:00
|
|
|
- push
|
|
|
|
branch:
|
|
|
|
- main
|
2022-06-23 12:52:40 +00:00
|
|
|
---
|
|
|
|
kind: pipeline
|
|
|
|
type: docker
|
|
|
|
name: hydra-deploy
|
|
|
|
|
|
|
|
steps:
|
2022-06-23 14:23:31 +00:00
|
|
|
- name: Wait for hydra job
|
|
|
|
image: alpine:latest
|
|
|
|
commands:
|
|
|
|
- apk add jq curl
|
|
|
|
- |
|
|
|
|
while true; do
|
2022-06-23 14:28:05 +00:00
|
|
|
if [[ $(curl https://git.chir.rs/api/v1/repos/darkkirb/nixos-config/commits/$DRONE_COMMIT/status | jq '[.statuses[] | select(.target_url | contains("https://hydra.chir.rs/"))] | length') != 0 ]]; then
|
2022-06-23 14:23:31 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
sleep 5
|
|
|
|
done
|
|
|
|
- name: Wait for hydra jobs to finish
|
|
|
|
image: alpine:latest
|
|
|
|
commands:
|
|
|
|
- apk add jq curl
|
|
|
|
- |
|
|
|
|
while true; do
|
2022-06-23 14:28:05 +00:00
|
|
|
if [[ $(curl https://git.chir.rs/api/v1/repos/darkkirb/nixos-config/commits/$DRONE_COMMIT/status | jq '[.statuses[] | select(.target_url | contains("https://hydra.chir.rs/")) | select(.status == "pending") ] | length') == 0 ]]; then
|
2022-06-23 14:23:31 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
sleep 5
|
|
|
|
done
|
|
|
|
- name: Deploy successful hydra jobs
|
|
|
|
image: alpine:latest
|
|
|
|
commands:
|
2022-06-23 15:12:03 +00:00
|
|
|
- apk add jq curl git openssh
|
2022-06-23 14:23:31 +00:00
|
|
|
- mkdir ~/.ssh
|
2022-06-23 16:01:29 +00:00
|
|
|
- echo "$SSH_KEY" > ~/.ssh/id_ed25519
|
2022-06-23 15:28:58 +00:00
|
|
|
- chmod 600 ~/.ssh/id_ed25519
|
2022-06-23 15:21:04 +00:00
|
|
|
- echo "git.chir.rs ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICQ77jA9S5qXDFGPLZRsC++AtxiXXeF8gVbkLlglx0GQ" > ~/.ssh/known_hosts
|
|
|
|
- echo "git.chir.rs ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDY0pZzNTAqaVqqfC31gYFixFs5KySv0UqvlDEAzEXJMB/pBWkE5GAd5Ik1NxD4QiAVWc2UARdmJEBbYf8mk5JiAv6fjsodJdJVRau4Ax7FtIfbxdFyzBgFery/KUnNIr6cmAWU2Af8JhzrnpEbhe5U3LftYnkdE1lI+iVqaQRARp0qikdzoAl3uMUhbdTxp1/6rtfN6bP2XZCsUx3t3W5ZG1QTQz8l7nrbXZX1TT3pZ2vcUANcMtOxEAwO6lbL210GX63C8XEoE7+4lLxRrSiaq3SkVlG07VspozKEtrrcsqCRNLebiaapmNWVoEq9Wd9VGAEjja5efyU6/HUlRogAOo1WP73UwoQLv5LTFH+ECoHhKS14xfPeXeVG8dbYyh5+CnmiVe43dH1qZw+ceYuYel31f47cAgScbxFvNkct0spK9m9mivnoUmYcxwTc+VbFbmnJvSuZw3a+OEYn9biitP/tTkYFiLZVdPZTxDkvd1oOyuVH9d4RMXbVgNS92/lr2iKFZkyhWMJ61hFMc2tupwmkp5Us5ce42XA0zC/aVY3vYoih/c5Ib0eZF1AEJdB6Bt5dWqITVsB3mip3Jn/mqVBIPTGXT6+FnGSEuL68Dj2yKBD7kj8YO/1SWpkVMy+bfoLXY/usgcaLCxpUu8dDrdrcKExLigCVbi3rdRmg7w==" >> ~/.ssh/known_hosts
|
|
|
|
- git remote set-url origin gitea@git.chir.rs:darkkirb/nixos-config.git
|
2022-06-23 14:23:31 +00:00
|
|
|
- |
|
2022-06-23 14:57:51 +00:00
|
|
|
for build in $(curl https://git.chir.rs/api/v1/repos/darkkirb/nixos-config/commits/$DRONE_COMMIT/status | jq -r '.statuses[] | select(.target_url | contains("https://hydra.chir.rs/")) | select(.status == "success" ) | .target_url'); do
|
2022-06-23 14:23:31 +00:00
|
|
|
JOB_JSON=$(curl -H "Accept: application/json" $build)
|
2022-06-23 15:05:37 +00:00
|
|
|
PROJECT=$(echo "$JOB_JSON" | jq -r '.project')
|
|
|
|
JOBSET=$(echo "$JOB_JSON" | jq -r '.jobset')
|
|
|
|
JOB=$(echo "$JOB_JSON" | jq -r '.job')
|
|
|
|
JOB_NAME="$PROJECT/$JOBSET/$JOB"
|
2022-06-23 14:23:31 +00:00
|
|
|
git branch $JOB_NAME || true
|
|
|
|
git checkout $JOB_NAME
|
|
|
|
git reset --hard $DRONE_COMMIT
|
2022-06-23 15:05:37 +00:00
|
|
|
git push --force -u origin $JOB_NAME
|
2022-06-23 14:23:31 +00:00
|
|
|
done
|
|
|
|
environment:
|
|
|
|
SSH_KEY:
|
|
|
|
from_secret: SSH_KEY
|
2022-06-23 12:52:40 +00:00
|
|
|
trigger:
|
|
|
|
event:
|
|
|
|
- push
|
2022-06-24 08:34:59 +00:00
|
|
|
branch:
|
|
|
|
- main
|