nixos-config/.forgejo/workflows/update_nix_flakes.yml

54 lines
1.2 KiB
YAML
Raw Normal View History

2024-07-20 22:32:37 +02:00
name: Update Nix flakes and commit changes
on:
schedule:
2024-07-20 23:19:11 +02:00
- cron: "5/10 * * * *"
2024-07-20 22:32:37 +02:00
jobs:
update-and-commit:
runs-on: native
steps:
2024-07-20 23:19:11 +02:00
- name: checkout repository
2024-07-20 22:32:37 +02:00
uses: actions/checkout@v2
with:
ref: "update"
2024-07-20 23:19:11 +02:00
- name: setup git
2024-07-20 22:32:37 +02:00
run: |
git config --local user.email "action@git.ingolf-wagner.de"
git config --local user.name "Forgejo Action"
2024-07-20 23:19:11 +02:00
- name: rebase with main branch
2024-07-20 22:32:37 +02:00
run: |
git fetch origin main
git rebase origin/main
2024-07-20 23:19:11 +02:00
- 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
2024-07-20 22:32:37 +02:00
run: nix flake update
2024-07-20 23:19:11 +02:00
- name: commit and push changes
2024-07-20 22:32:37 +02:00
run: |
git diff --quiet && git diff --staged --quiet || (git commit -am "Update Nix flakes" && git push)
2024-07-20 23:19:11 +02:00
- name: teardown ssh
if: always()
run: |
echo $SSH_AGENT_PID
kill $SSH_AGENT_PID