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

50 lines
1.1 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-21 10:29:26 +02:00
- cron: "40 10 * * *" # not to frequent, GitHub only allows a few pulls per hour
2024-07-20 22:32:37 +02:00
jobs:
update-and-commit:
runs-on: native
steps:
2024-07-21 00:08:51 +02:00
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-21 00:55:13 +02:00
depth: 0
2024-07-20 22:32:37 +02:00
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-21 00:08:51 +02:00
# fixme: not working for some reason
#- name: rebase with main branch
# run: |
# git fetch origin main
# git rebase origin/main
2024-07-20 22:32:37 +02:00
2024-07-21 10:29:26 +02:00
- name: update nix flakes
2024-07-20 23:19:11 +02:00
run: |
2024-07-21 10:29:26 +02:00
cat <<EOF > .ssh_key
2024-07-20 23:19:11 +02:00
${{ secrets.SSH_KEY }}
EOF
2024-07-21 10:29:26 +02:00
chmod 600 .ssh_key
2024-07-20 23:19:11 +02:00
eval $(ssh-agent)
2024-07-21 10:29:26 +02:00
ssh-add .ssh_key
2024-07-20 23:19:11 +02:00
2024-07-21 10:29:26 +02:00
nix flake update
2024-07-21 10:09:56 +02:00
export GITHUB_TOKEN=""
2024-07-21 10:29:26 +02:00
2024-07-20 23:25:07 +02:00
git diff --quiet && \
git diff --staged --quiet || \
(git commit -am "Update Nix flakes" && git push)
2024-07-21 10:29:26 +02:00
2024-07-20 23:19:11 +02:00
echo $SSH_AGENT_PID
kill $SSH_AGENT_PID