mirror of
https://codeberg.org/tmayoff/.dotfiles.git
synced 2025-12-06 08:48:34 -05:00
Reviewed-on: https://codeberg.org/tmayoff/.dotfiles/pulls/42 Co-authored-by: Tyler Mayoff <tyler@tylermayoff.com> Co-committed-by: Tyler Mayoff <tyler@tylermayoff.com>
54 lines
1.6 KiB
YAML
54 lines
1.6 KiB
YAML
name: "Flake lock updater"
|
|
description: "Updates the flake lock file"
|
|
inputs:
|
|
flake_path:
|
|
description: "Relative path to the flake.nix file"
|
|
default: './'
|
|
required: false
|
|
token:
|
|
description: "Authentication token"
|
|
default: ""
|
|
required: true
|
|
|
|
runs:
|
|
using: "composite"
|
|
steps:
|
|
- name: Update flake.lock
|
|
id: update
|
|
shell: bash
|
|
run: |
|
|
nix flake update --flake ${{ inputs.flake_path }} 2> >(tee /dev/stderr) | awk '
|
|
/^• Updated input/ {in_update = 1; print; next}
|
|
in_update && !/^warning:/ {print}
|
|
/^$/ {in_update = 0}
|
|
' > update.log
|
|
|
|
echo "UPDATE_LOG<<EOF" >> $GITHUB_ENV
|
|
cat update.log >> $GITHUB_ENV
|
|
echo "EOF" >> $GITHUB_ENV
|
|
|
|
rm update.log
|
|
|
|
- name: Create PR
|
|
shell: bash
|
|
run: |
|
|
BRANCH="update-flake-lock"
|
|
|
|
git fetch origin
|
|
git checkout main
|
|
|
|
if git show-ref --verify --quiet refs/heads/$BRANCH; then
|
|
git checkout $BRANCH
|
|
git reset --hard origin/main
|
|
else
|
|
git checkout -b $BRANCH origin/main
|
|
fi
|
|
|
|
git checkout -B update-flake-lock
|
|
git add ${{ inputs.flake_path }}/flake.lock
|
|
git config user.name "${{ env.GITHUB_ACTOR }}"
|
|
git config user.email "tyler@mayoff.ca"
|
|
git commit -m "updated lockfile"
|
|
git push origin update-flake-lock
|
|
nix run nixpkgs#forgejo-cli -- auth add-key ${{ env.GITHUB_ACTOR }} ${{ inputs.token }}
|
|
nix run nixpkgs#forgejo-cli -- pr create "automated: Update flake.lock" --body "body tests" --head update-flake-lock || echo "PR may already exist"
|