feat(npins-update): Make it run weekly, but per pin
All checks were successful
Check meta / check_meta (pull_request) Successful in 17s
Check meta / check_dns (pull_request) Successful in 18s
Check workflows / check_workflows (pull_request) Successful in 26s
Build all the nodes / ap01 (pull_request) Successful in 1m4s
Build all the nodes / bridge01 (pull_request) Successful in 1m49s
Build all the nodes / geo01 (pull_request) Successful in 2m0s
Build all the nodes / geo02 (pull_request) Successful in 1m52s
Build all the nodes / hypervisor01 (pull_request) Successful in 1m58s
Build all the nodes / hypervisor02 (pull_request) Successful in 1m38s
Build all the nodes / netcore02 (pull_request) Successful in 36s
Build all the nodes / compute01 (pull_request) Successful in 2m53s
Build all the nodes / hypervisor03 (pull_request) Successful in 1m51s
Build all the nodes / rescue01 (pull_request) Successful in 2m13s
Build all the nodes / tower01 (pull_request) Successful in 1m59s
Build all the nodes / storage01 (pull_request) Successful in 2m24s
Build all the nodes / vault01 (pull_request) Successful in 2m11s
Build the shell / build-shell (pull_request) Successful in 38s
Build all the nodes / web02 (pull_request) Successful in 1m47s
Run pre-commit on all files / pre-commit (pull_request) Successful in 35s
Build all the nodes / web01 (pull_request) Successful in 2m34s
Build all the nodes / web03 (pull_request) Successful in 1m40s
Check workflows / check_workflows (push) Successful in 29s
Build all the nodes / ap01 (push) Successful in 1m15s
Build all the nodes / geo01 (push) Successful in 2m1s
Build all the nodes / bridge01 (push) Successful in 2m1s
Build all the nodes / geo02 (push) Successful in 2m12s
Build all the nodes / hypervisor01 (push) Successful in 1m47s
Build all the nodes / netcore02 (push) Successful in 32s
Build all the nodes / hypervisor02 (push) Successful in 1m32s
Build all the nodes / compute01 (push) Successful in 2m59s
Build all the nodes / hypervisor03 (push) Successful in 1m43s
Build all the nodes / rescue01 (push) Successful in 2m9s
Build all the nodes / storage01 (push) Successful in 2m13s
Build all the nodes / tower01 (push) Successful in 2m2s
Build all the nodes / vault01 (push) Successful in 2m2s
Build the shell / build-shell (push) Successful in 31s
Run pre-commit on all files / pre-commit (push) Successful in 34s
Build all the nodes / web01 (push) Successful in 2m23s
Build all the nodes / web02 (push) Successful in 2m2s
Build all the nodes / web03 (push) Successful in 1m40s
All checks were successful
Check meta / check_meta (pull_request) Successful in 17s
Check meta / check_dns (pull_request) Successful in 18s
Check workflows / check_workflows (pull_request) Successful in 26s
Build all the nodes / ap01 (pull_request) Successful in 1m4s
Build all the nodes / bridge01 (pull_request) Successful in 1m49s
Build all the nodes / geo01 (pull_request) Successful in 2m0s
Build all the nodes / geo02 (pull_request) Successful in 1m52s
Build all the nodes / hypervisor01 (pull_request) Successful in 1m58s
Build all the nodes / hypervisor02 (pull_request) Successful in 1m38s
Build all the nodes / netcore02 (pull_request) Successful in 36s
Build all the nodes / compute01 (pull_request) Successful in 2m53s
Build all the nodes / hypervisor03 (pull_request) Successful in 1m51s
Build all the nodes / rescue01 (pull_request) Successful in 2m13s
Build all the nodes / tower01 (pull_request) Successful in 1m59s
Build all the nodes / storage01 (pull_request) Successful in 2m24s
Build all the nodes / vault01 (pull_request) Successful in 2m11s
Build the shell / build-shell (pull_request) Successful in 38s
Build all the nodes / web02 (pull_request) Successful in 1m47s
Run pre-commit on all files / pre-commit (pull_request) Successful in 35s
Build all the nodes / web01 (pull_request) Successful in 2m34s
Build all the nodes / web03 (pull_request) Successful in 1m40s
Check workflows / check_workflows (push) Successful in 29s
Build all the nodes / ap01 (push) Successful in 1m15s
Build all the nodes / geo01 (push) Successful in 2m1s
Build all the nodes / bridge01 (push) Successful in 2m1s
Build all the nodes / geo02 (push) Successful in 2m12s
Build all the nodes / hypervisor01 (push) Successful in 1m47s
Build all the nodes / netcore02 (push) Successful in 32s
Build all the nodes / hypervisor02 (push) Successful in 1m32s
Build all the nodes / compute01 (push) Successful in 2m59s
Build all the nodes / hypervisor03 (push) Successful in 1m43s
Build all the nodes / rescue01 (push) Successful in 2m9s
Build all the nodes / storage01 (push) Successful in 2m13s
Build all the nodes / tower01 (push) Successful in 2m2s
Build all the nodes / vault01 (push) Successful in 2m2s
Build the shell / build-shell (push) Successful in 31s
Run pre-commit on all files / pre-commit (push) Successful in 34s
Build all the nodes / web01 (push) Successful in 2m23s
Build all the nodes / web02 (push) Successful in 2m2s
Build all the nodes / web03 (push) Successful in 1m40s
This commit is contained in:
parent
2551da6388
commit
4a911b26c6
2 changed files with 944 additions and 71 deletions
|
@ -2,63 +2,90 @@
|
|||
#
|
||||
# SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
{ nix-actions, ... }:
|
||||
{ lib, nix-actions, ... }:
|
||||
|
||||
let
|
||||
inherit (nix-actions.lib) secret;
|
||||
|
||||
inherit (lib) genAttrs mapAttrs' nameValuePair;
|
||||
|
||||
dependencies = builtins.attrNames (import ../npins);
|
||||
in
|
||||
|
||||
{
|
||||
name = "npins update";
|
||||
name = "Update dependencies";
|
||||
on.schedule = [
|
||||
# Run at 15:25 everyday
|
||||
{ cron = "25 15 * * *"; }
|
||||
# Run at 15:25 every saturday
|
||||
{ cron = "25 15 * * 6"; }
|
||||
];
|
||||
|
||||
jobs.npins_update = {
|
||||
runs-on = "nix";
|
||||
steps = [
|
||||
(nix-actions.steps.checkout {
|
||||
fetch-depth = 0;
|
||||
token = nix-actions.lib.secret "TEA_DGNUM_CHORES_TOKEN";
|
||||
})
|
||||
|
||||
{
|
||||
name = "Update dependencies and open PR if necessary";
|
||||
run = # bash
|
||||
''
|
||||
npins update
|
||||
|
||||
if [ ! -z "$(git diff --name-only)" ]; then
|
||||
echo "[+] Changes detected, pushing updates."
|
||||
|
||||
git switch -C npins-update
|
||||
|
||||
git add npins
|
||||
|
||||
git commit --message "chore(npins): Update"
|
||||
git push --set-upstream origin npins-update --force
|
||||
|
||||
# Connect to the server with the cli
|
||||
tea login add \
|
||||
-n dgnum-chores \
|
||||
-t "${nix-actions.lib.secret "TEA_DGNUM_CHORES_TOKEN"}" \
|
||||
-u https://git.dgnum.eu
|
||||
|
||||
# Create a pull request if needed
|
||||
# i.e. no PR with the same title exists
|
||||
if [ -z "$(tea pr ls -f='title,author' -o simple | grep 'chore(npins): Update dgnum-chores')" ]; then
|
||||
tea pr create \
|
||||
--description "Automatic npins update" \
|
||||
--title "chore(npins): Update" \
|
||||
--head npins-update
|
||||
fi
|
||||
fi
|
||||
'';
|
||||
|
||||
env = {
|
||||
GIT_AUTHOR_NAME = "DGNum Chores";
|
||||
GIT_AUTHOR_EMAIL = "tech@dgnum.eu";
|
||||
GIT_COMMITTER_NAME = "DGNum Chores";
|
||||
GIT_COMMITTER_EMAIL = "tech@dgnum.eu";
|
||||
};
|
||||
}
|
||||
];
|
||||
# Global environment, necessary for rebases and commits
|
||||
env = rec {
|
||||
GIT_AUTHOR_NAME = "HT Chores";
|
||||
GIT_AUTHOR_EMAIL = "chores@mail.hubrecht.ovh";
|
||||
GIT_COMMITTER_NAME = GIT_AUTHOR_NAME;
|
||||
GIT_COMMITTER_EMAIL = GIT_AUTHOR_EMAIL;
|
||||
};
|
||||
|
||||
jobs = mapAttrs' (name: nameValuePair (builtins.replaceStrings [ "." ] [ "_" ] name)) (
|
||||
genAttrs dependencies (name: {
|
||||
runs-on = "nix";
|
||||
steps = [
|
||||
(nix-actions.steps.checkout {
|
||||
fetch-depth = 0;
|
||||
token = secret "TEA_DGNUM_CHORES_TOKEN";
|
||||
})
|
||||
|
||||
{
|
||||
env = {
|
||||
GIT_UPDATE_BRANCH = "npins-updates/${name}";
|
||||
COMMIT_MESSAGE = "chore(npins): Update ${name}";
|
||||
};
|
||||
|
||||
name = "Switch to a new branch";
|
||||
run = # bash
|
||||
''
|
||||
if git ls-remote --exit-code --heads origin "refs/heads/$GIT_UPDATE_BRANCH"; then
|
||||
git switch "$GIT_UPDATE_BRANCH"
|
||||
git rebase main
|
||||
echo "EXISTING_BRANCH=1" >> $GITHUB_ENV
|
||||
else
|
||||
git switch -C "$GIT_UPDATE_BRANCH"
|
||||
fi
|
||||
'';
|
||||
}
|
||||
|
||||
{
|
||||
name = "Open a PR if updates are present";
|
||||
run = # bash
|
||||
''
|
||||
npins update ${name}
|
||||
|
||||
if [ ! -z "$(git diff --name-only)" ]; then
|
||||
echo "[+] Changes detected, pushing updates."
|
||||
|
||||
git add npins
|
||||
|
||||
if [ "$EXISTING_BRANCH" -eq "1" ]; then
|
||||
git commit --amend --no-edit
|
||||
git push --force
|
||||
else
|
||||
git commit --message "$COMMIT_MESSAGE"
|
||||
git push -u origin "$GIT_UPDATE_BRANCH"
|
||||
fi
|
||||
|
||||
# Connect to the server with the cli
|
||||
tea login add -n dgnum-chores -t "${secret "TEA_DGNUM_CHORES_TOKEN"}" -u https://git.dgnum.eu
|
||||
|
||||
# Create a pull request if needed
|
||||
# i.e. no PR with the same title exists
|
||||
if [ -z $(tea pr ls -f='title,author' -o simple | grep "$COMMIT_MESSAGE dgnum-chores") ]; then
|
||||
tea pr create --description "Automatic npins update" --title "$COMMIT_MESSAGE" --head "$GIT_UPDATE_BRANCH"
|
||||
fi
|
||||
fi
|
||||
'';
|
||||
}
|
||||
];
|
||||
})
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue