From 729ffe95846ba5f195aad5a7e19270e2d484f42d Mon Sep 17 00:00:00 2001 From: Ingolf Wagner Date: Sun, 21 Jul 2024 10:29:26 +0200 Subject: [PATCH] try to fix the git push frogejo action --- .forgejo/workflows/nix_build.yaml | 50 ++++++++++++------------ .forgejo/workflows/update_nix_flakes.yml | 25 +++++------- 2 files changed, 34 insertions(+), 41 deletions(-) diff --git a/.forgejo/workflows/nix_build.yaml b/.forgejo/workflows/nix_build.yaml index 15da3dc..bef39d9 100644 --- a/.forgejo/workflows/nix_build.yaml +++ b/.forgejo/workflows/nix_build.yaml @@ -9,31 +9,31 @@ jobs: steps: - uses: actions/checkout@v4 - - 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 - - - run: nix flake archive - - - name: teardown ssh - if: always() - run: | - echo $SSH_AGENT_PID - kill $SSH_AGENT_PID - - - name: nix flake check - run: nix flake check --verbose --log-format raw +# - 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 +# +# - run: nix flake archive +# +# - name: teardown ssh +# if: always() +# run: | +# echo $SSH_AGENT_PID +# kill $SSH_AGENT_PID +# +# - name: nix flake check +# run: nix flake check --verbose --log-format raw #- name: nix build orbi diff --git a/.forgejo/workflows/update_nix_flakes.yml b/.forgejo/workflows/update_nix_flakes.yml index 2aa80a8..ac68cf4 100644 --- a/.forgejo/workflows/update_nix_flakes.yml +++ b/.forgejo/workflows/update_nix_flakes.yml @@ -2,7 +2,7 @@ name: Update Nix flakes and commit changes on: schedule: - - cron: "20 10 * * *" # not to frequent, GitHub only allows a few pulls per hour + - cron: "40 10 * * *" # not to frequent, GitHub only allows a few pulls per hour jobs: update-and-commit: @@ -27,35 +27,28 @@ jobs: # git fetch origin main # git rebase origin/main - - name: setup ssh + - name: update nix flakes run: | - cat < .id_rsa + cat < .ssh_key ${{ secrets.SSH_KEY }} EOF - chmod 600 .id_rsa + chmod 600 .ssh_key eval $(ssh-agent) - ssh-add .id_rsa + ssh-add .ssh_key cat < "$GITHUB_ENV" SSH_AUTH_SOCK="$SSH_AUTH_SOCK" SSH_AGENT_PID=$SSH_AGENT_PID EOF - - name: update nix flakes - run: nix flake update - - # we need the ssh-agent here, otherwise git push would use the GITHUB_TOKEN - # which prevents other workflows to be triggered - - name: commit and push changes - run: | + nix flake update + export GITHUB_TOKEN="" + 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