From 34a42131b21343748ab69f2c8e17c59521a3a15d Mon Sep 17 00:00:00 2001 From: Ingolf Wagner Date: Sat, 20 Jul 2024 23:19:11 +0200 Subject: [PATCH] try to fix update routine --- .forgejo/workflows/update_nix_flakes.yml | 34 +++++++++++++++++++----- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/.forgejo/workflows/update_nix_flakes.yml b/.forgejo/workflows/update_nix_flakes.yml index a99fd9b..bba8d06 100644 --- a/.forgejo/workflows/update_nix_flakes.yml +++ b/.forgejo/workflows/update_nix_flakes.yml @@ -2,32 +2,52 @@ name: Update Nix flakes and commit changes on: schedule: - - cron: "0 23 * * *" + - cron: "5/10 * * * *" jobs: update-and-commit: runs-on: native steps: - - name: Checkout repository + - name: checkout repository uses: actions/checkout@v2 with: ref: "update" - fetch-depth: 0 - - name: Setup Git + - 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 + - name: rebase with main branch run: | git fetch origin main git rebase origin/main - - name: Update Nix flakes + - name: setup ssh + run: | + cat < .id_rsa + ${{ secrets.SSH_KEY }} + EOF + chmod 600 .id_rsa + + eval $(ssh-agent) + ssh-add .id_rsa + + cat < "$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 + - 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