workflows to update specific inputs
This commit is contained in:
parent
c5bbdc7a4c
commit
50bfc1ac6b
1 changed files with 24 additions and 6 deletions
|
|
@ -3,7 +3,16 @@ name: flake update
|
||||||
on:
|
on:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '0 3 * * *'
|
- cron: '0 3 * * *'
|
||||||
workflow_dispatch: {}
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
target:
|
||||||
|
description: 'Inputs to update'
|
||||||
|
type: choice
|
||||||
|
default: all
|
||||||
|
options:
|
||||||
|
- all
|
||||||
|
- hyperhive
|
||||||
|
- trollshell
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
update:
|
update:
|
||||||
|
|
@ -11,23 +20,32 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- uses: https://code.forgejo.org/actions/checkout@v4
|
- uses: https://code.forgejo.org/actions/checkout@v4
|
||||||
- run: |
|
- run: |
|
||||||
nix flake update
|
target="${{ github.event.inputs.target }}"
|
||||||
|
target="${target:-all}"
|
||||||
|
|
||||||
|
case "$target" in
|
||||||
|
all) inputs="" ;;
|
||||||
|
hyperhive) inputs="hyperhive hyperhive-website" ;;
|
||||||
|
trollshell) inputs="trollshell" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
nix flake update $inputs
|
||||||
|
|
||||||
if git diff --quiet -- flake.lock; then
|
if git diff --quiet -- flake.lock; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
branch="flake-update-$(date +%F)"
|
branch="flake-update-${target}-$(date +%F)"
|
||||||
git checkout -b "$branch"
|
git checkout -b "$branch"
|
||||||
git -c user.name="flake-bot" -c user.email="git+flake-bot@darkest.space" \
|
git -c user.name="flake-bot" -c user.email="git+flake-bot@darkest.space" \
|
||||||
commit -am "nix flake update"
|
commit -am "nix flake update ($target)"
|
||||||
git push "https://flake-bot:${PR_BOT_TOKEN}@forge.darkest.space/mara/nixos-configs.git" "$branch"
|
git push "https://flake-bot:${PR_BOT_TOKEN}@forge.darkest.space/mara/nixos-configs.git" "$branch"
|
||||||
|
|
||||||
curl -sf -X POST \
|
curl -sf -X POST \
|
||||||
-H "Authorization: token ${PR_BOT_TOKEN}" \
|
-H "Authorization: token ${PR_BOT_TOKEN}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d "$(jq -n --arg h "$branch" \
|
-d "$(jq -n --arg h "$branch" --arg t "$target" \
|
||||||
'{title: "nix flake update", head: $h, base: "main"}')" \
|
'{title: ("nix flake update (" + $t + ")"), head: $h, base: "main"}')" \
|
||||||
"https://forge.darkest.space/api/v1/repos/mara/nixos-configs/pulls"
|
"https://forge.darkest.space/api/v1/repos/mara/nixos-configs/pulls"
|
||||||
env:
|
env:
|
||||||
PR_BOT_TOKEN: ${{ secrets.PR_BOT_TOKEN }}
|
PR_BOT_TOKEN: ${{ secrets.PR_BOT_TOKEN }}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue