try to fix the git push frogejo action
All checks were successful
Build all NixOS Configurations / nix build (push) Successful in 5s

This commit is contained in:
Ingolf Wagner 2024-07-21 10:29:26 +02:00
parent 2b50c8f39f
commit 729ffe9584
Signed by: palo
GPG key ID: 76BF5F1928B9618B
2 changed files with 34 additions and 41 deletions

View file

@ -9,31 +9,31 @@ jobs:
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: setup ssh # - name: setup ssh
run: | # run: |
cat <<EOF > .id_rsa # cat <<EOF > .id_rsa
${{ secrets.SSH_KEY }} # ${{ secrets.SSH_KEY }}
EOF # EOF
chmod 600 .id_rsa # chmod 600 .id_rsa
#
eval $(ssh-agent) # eval $(ssh-agent)
ssh-add .id_rsa # ssh-add .id_rsa
#
cat <<EOF > "$GITHUB_ENV" # cat <<EOF > "$GITHUB_ENV"
SSH_AUTH_SOCK="$SSH_AUTH_SOCK" # SSH_AUTH_SOCK="$SSH_AUTH_SOCK"
SSH_AGENT_PID=$SSH_AGENT_PID # SSH_AGENT_PID=$SSH_AGENT_PID
EOF # EOF
#
- run: nix flake archive # - run: nix flake archive
#
- name: teardown ssh # - name: teardown ssh
if: always() # if: always()
run: | # run: |
echo $SSH_AGENT_PID # echo $SSH_AGENT_PID
kill $SSH_AGENT_PID # kill $SSH_AGENT_PID
#
- name: nix flake check # - name: nix flake check
run: nix flake check --verbose --log-format raw # run: nix flake check --verbose --log-format raw
#- name: nix build orbi #- name: nix build orbi

View file

@ -2,7 +2,7 @@ name: Update Nix flakes and commit changes
on: on:
schedule: 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: jobs:
update-and-commit: update-and-commit:
@ -27,35 +27,28 @@ jobs:
# git fetch origin main # git fetch origin main
# git rebase origin/main # git rebase origin/main
- name: setup ssh - name: update nix flakes
run: | run: |
cat <<EOF > .id_rsa cat <<EOF > .ssh_key
${{ secrets.SSH_KEY }} ${{ secrets.SSH_KEY }}
EOF EOF
chmod 600 .id_rsa chmod 600 .ssh_key
eval $(ssh-agent) eval $(ssh-agent)
ssh-add .id_rsa ssh-add .ssh_key
cat <<EOF > "$GITHUB_ENV" cat <<EOF > "$GITHUB_ENV"
SSH_AUTH_SOCK="$SSH_AUTH_SOCK" SSH_AUTH_SOCK="$SSH_AUTH_SOCK"
SSH_AGENT_PID=$SSH_AGENT_PID SSH_AGENT_PID=$SSH_AGENT_PID
EOF EOF
- name: update nix flakes nix flake update
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: |
export GITHUB_TOKEN="" export GITHUB_TOKEN=""
git diff --quiet && \ git diff --quiet && \
git diff --staged --quiet || \ git diff --staged --quiet || \
(git commit -am "Update Nix flakes" && git push) (git commit -am "Update Nix flakes" && git push)
- name: teardown ssh
if: always()
run: |
echo $SSH_AGENT_PID echo $SSH_AGENT_PID
kill $SSH_AGENT_PID kill $SSH_AGENT_PID