try to fix the git push frogejo action

This commit is contained in:
Ingolf Wagner 2024-07-21 12:15:56 +02:00
parent 4e9205322c
commit dc21678ad3
No known key found for this signature in database
GPG key ID: 76BF5F1928B9618B
2 changed files with 71 additions and 76 deletions

View file

@ -1,41 +1,85 @@
name: Build all NixOS Configurations
on:
- push
push:
branches:
- '**'
schedule:
- cron: "20 12 * * *" # not to frequent, GitHub only allows a few pulls per hour
jobs:
nix build:
runs-on: native
steps:
- uses: actions/checkout@v4
# - name: setup ssh
# run: |
# cat <<EOF > .id_rsa
# ${{ secrets.SSH_KEY }}
# EOF
# chmod 600 .id_rsa
#
# eval $(ssh-agent)
# ssh-add .id_rsa
#
# nix flake archive
#
# echo $SSH_AGENT_PID
# kill $SSH_AGENT_PID
#
# - name: nix flake check
# run: nix flake check --verbose --log-format raw
- name: checkout repository
if: github.event_name != 'schedule'
uses: actions/checkout@v2
with:
depth: 0
- name: checkout repository (branch update)
if: github.event_name == 'schedule'
uses: actions/checkout@v2
with:
ref: "update"
depth: 0
#- name: nix build orbi
# run: nix build .#nixosConfigurations.orbi.config.system.build.toplevel
- name: update nix flakes (branch update)
if: github.event_name == 'schedule'
run: |
cat <<EOF > .ssh_key
${{ secrets.SSH_KEY }}
EOF
chmod 600 .ssh_key
#- name: nix build cream
# run: nix build .#nixosConfigurations.cream.config.system.build.toplevel
eval $(ssh-agent)
ssh-add .ssh_key
#- name: nix build cherry
# run: nix build .#nixosConfigurations.cherry.config.system.build.toplevel
nix flake update
echo $SSH_AGENT_PID
kill $SSH_AGENT_PID
rm .ssh_key
- name: fetch and check
run: |
cat <<EOF > .ssh_key
${{ secrets.SSH_KEY }}
EOF
chmod 600 .ssh_key
eval $(ssh-agent)
ssh-add .ssh_key
nix flake archive
nix flake check --verbose --log-format raw
echo $SSH_AGENT_PID
kill $SSH_AGENT_PID
rm .ssh_key
- name: nix build orbi
run: nix build .#nixosConfigurations.orbi.config.system.build.toplevel
- name: nix build cream
run: nix build .#nixosConfigurations.cream.config.system.build.toplevel
- name: nix build cherry
run: nix build .#nixosConfigurations.cherry.config.system.build.toplevel
- name: nix build chungus
run: nix build .#nixosConfigurations.chungus.config.system.build.toplevel
- name: push if all fine (branch update)
if: github.event_name == 'schedule'
run: |
git config --local user.email "action@git.ingolf-wagner.de"
git config --local user.name "Forgejo Action"
git diff --quiet && \
git diff --staged --quiet || \
(git commit -am "Update Nix flakes" && git push)
#- name: nix build chungus
# run: nix build .#nixosConfigurations.chungus.config.system.build.toplevel

View file

@ -1,49 +0,0 @@
name: Update Nix flakes and commit changes
on:
schedule:
- cron: "30 11 * * *" # not to frequent, GitHub only allows a few pulls per hour
jobs:
update-and-commit:
runs-on: native
steps:
- name: checkout repository
uses: actions/checkout@v2
with:
ref: "update"
depth: 0
- name: setup git
run: |
git config --local user.email "action@git.ingolf-wagner.de"
git config --local user.name "Forgejo Action"
# fixme: not working for some reason
#- name: rebase with main branch
# run: |
# git fetch origin main
# git rebase origin/main
- name: update nix flakes
run: |
cat <<EOF > .ssh_key
${{ secrets.SSH_KEY }}
EOF
chmod 600 .ssh_key
eval $(ssh-agent)
ssh-add .ssh_key
nix flake update
export GIT_SSH_COMMAND="ssh -i .ssh_key -F /dev/null"
git diff --quiet && \
git diff --staged --quiet || \
(git commit -am "Update Nix flakes" && git push)
echo $SSH_AGENT_PID
kill $SSH_AGENT_PID