mirror of
https://codeberg.org/tmayoff/.dotfiles.git
synced 2025-12-06 08:48:34 -05:00
Use reuseable action for flake update actions (#42)
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>
This commit is contained in:
parent
e93090ba51
commit
44ad567b17
3 changed files with 105 additions and 60 deletions
54
.forgejo/actions/flake-update/action.yml
Normal file
54
.forgejo/actions/flake-update/action.yml
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
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"
|
||||
Loading…
Add table
Add a link
Reference in a new issue