nixos-config/.forgejo/workflows/update_nix_flakes.yml
Ingolf Wagner 399c99aa44
All checks were successful
Build all NixOS Configurations / nix build (push) Successful in 6m54s
try to fix update routine
2024-07-20 23:25:07 +02:00

56 lines
1.2 KiB
YAML

name: Update Nix flakes and commit changes
on:
schedule:
- cron: "5/10 * * * *"
jobs:
update-and-commit:
runs-on: native
steps:
- name: checkout repository
uses: actions/checkout@v2
with:
ref: "update"
- name: setup git
run: |
git config --local user.email "action@git.ingolf-wagner.de"
git config --local user.name "Forgejo Action"
- name: rebase with main branch
run: |
git fetch origin main
git rebase origin/main
- name: setup ssh
run: |
cat <<EOF > .id_rsa
${{ secrets.SSH_KEY }}
EOF
chmod 600 .id_rsa
eval $(ssh-agent)
ssh-add .id_rsa
cat <<EOF > "$GITHUB_ENV"
SSH_AUTH_SOCK="$SSH_AUTH_SOCK"
SSH_AGENT_PID=$SSH_AGENT_PID
EOF
- name: update nix flakes
run: nix flake update
- name: commit and push changes
run: |
git diff --quiet && \
git diff --staged --quiet || \
(git commit -am "Update Nix flakes" && git push)
- name: teardown ssh
if: always()
run: |
echo $SSH_AGENT_PID
kill $SSH_AGENT_PID