feat: updated format actions with forgejo workflows to have full cacheing
All checks were successful
ci / nix-fmt (push) Successful in 10m2s

This commit is contained in:
Ceferino Patino 2025-12-07 14:41:31 -06:00
commit 1732a55e73
Signed by: c4patino
SSH key fingerprint: SHA256:Wu+cU1t+7zVT9wzew/4meNmeulo66NzMqc22MdDBgXI

View file

@ -5,44 +5,51 @@ on:
branches: ["main"] branches: ["main"]
workflow_dispatch: workflow_dispatch:
env:
USER: runner
jobs: jobs:
nix-fmt: nix-fmt:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: checkout code
uses: actions/checkout@v6.0.1
- name: install nix - name: install nix
uses: https://github.com/cachix/install-nix-action@v31.8.4 uses: https://github.com/cachix/install-nix-action@v31.8.4
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: set up nix - name: set up nix
run: | run: |
mkdir -p ~/.config/nix mkdir -p ~/.config/nix
echo "experimental-features = nix-command flakes pipe-operators" >> ~/.config/nix/nix.conf echo "experimental-features = nix-command flakes pipe-operators" >> ~/.config/nix/nix.conf
nix-channel --add https://nixos.org/channels/nixos-unstable nixpkgs nix-channel --add https://nixos.org/channels/nixos-unstable nixpkgs
nix-channel --update nix-channel --update
- name: restore and save nix store
uses: https://github.com/nix-community/cache-nix-action@v6.1.3
with:
primary-key: nix-${{ runner.os }}-${{ hashFiles('**/*.nix', '**/flake.lock') }}
restore-prefixes-first-match: nix-${{ runner.os }}-
gc-max-store-size-linux: 1G
purge: true
purge-prefixes: nix-${{ runner.os }}-
purge-created: 0
purge-last-accessed: 0
purge-primary-key: never
- name: set up nix-community cachix - name: set up nix-community cachix
uses: https://github.com/cachix/cachix-action@v16 uses: https://github.com/cachix/cachix-action@v16
with: with:
name: nix-community name: nix-community
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
- name: setup git identity
run: |
git config --global user.name "forgejo-actions-bot"
git config --global user.email "actions@forgejo.local"
- name: import gpg key - name: import gpg key
env: env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
run: | run: |
echo "$GPG_PRIVATE_KEY" | gpg --batch --import || true echo "$GPG_PRIVATE_KEY" | gpg --batch --import || true
echo "default-cache-ttl 3600" >> ~/.gnupg/gpg-agent.conf
echo RELOADAGENT | gpg-connect-agent
- name: setup git identity
run: |
git config --global user.name "forgejo-actions-bot"
git config --global user.email "actions@forgejo.local"
KEYID=$(gpg --list-secret-keys --with-colons | awk -F: '/^sec/{print $5;exit}') KEYID=$(gpg --list-secret-keys --with-colons | awk -F: '/^sec/{print $5;exit}')
git config --global user.signingkey "$KEYID" git config --global user.signingkey "$KEYID"
git config --global commit.gpgsign true git config --global commit.gpgsign true
echo "default-cache-ttl 3600" >> ~/.gnupg/gpg-agent.conf
echo RELOADAGENT | gpg-connect-agent
- name: checkout code
uses: actions/checkout@v5.0.0
- name: run nix fmt - name: run nix fmt
run: nix fmt run: nix fmt
- name: check for changes - name: check for changes
@ -56,10 +63,9 @@ jobs:
- name: commit and push changes - name: commit and push changes
if: steps.git_status.outputs.changed == 'true' if: steps.git_status.outputs.changed == 'true'
env: env:
TOKEN: ${{ secrets.ACTIONS_TOKEN }} FORGEJO_TOKEN: ${{ forgejo.token }}
GITEA_SERVER: git.cpatino.com FORGEJO_REPOSITORY: ${{ forgejo.repository }}
GITEA_REPO: c4patino/yumevim
run: | run: |
git add -A git add -A
git commit -S -m "style: autoformatting all files with treefmt" git commit -S -m "style: autoformatting all files with treefmt"
git push "https://forgejo:${TOKEN}@${GITEA_SERVER}/${GITEA_REPO}.git" HEAD:main git push "https://${FORGEJO_TOKEN}@git.cpatino.com/${FORGEJO_REPOSITORY}.git" HEAD:main