yumeami/.forgejo/workflows/ci.yml

65 lines
2.3 KiB
YAML
Executable file

name: ci
on:
push:
branches: ["main"]
workflow_dispatch:
jobs:
nix-fmt:
runs-on: nixos-latest
steps:
- name: set up nix
run: |
mkdir -p ~/.config/nix
echo "experimental-features = nix-command flakes pipe-operators" >> ~/.config/nix/nix.conf
nix-env -iA nixpkgs.nodejs
- 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: 1G
- name: set up nix-community cachix
uses: https://github.com/cachix/cachix-action@v16
with:
name: nix-community
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
- name: checkout code
uses: actions/checkout@v5.0.0
- 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
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
run: |
nix-env -iA nixpkgs.gawk nixpkgs.gnupg
echo "$GPG_PRIVATE_KEY" | gpg --batch --import || true
KEYID=$(gpg --list-secret-keys --with-colons | awk -F: '/^sec/{print $5;exit}')
git config --global user.signingkey "$KEYID"
git config --global commit.gpgsign true
echo "default-cache-ttl 3600" >> ~/.gnupg/gpg-agent.conf
echo RELOADAGENT | gpg-connect-agent
- name: run nix fmt
run: nix fmt
- name: check for changes
id: git_status
run: |
if [[ -n "$(git status --porcelain)" ]]; then
echo "changed=true" >> $GITHUB_OUTPUT
else
echo "changed=false" >> $GITHUB_OUTPUT
fi
- name: commit and push changes
if: steps.git_status.outputs.changed == 'true'
env:
TOKEN: ${{ secrets.ACTIONS_TOKEN }}
GITEA_SERVER: git.cpatino.com
GITEA_REPO: c4patino/yumeami
run: |
git add -A
git commit -S -m "style: autoformatting all files with treefmt"
git push "https://forgejo:${TOKEN}@${GITEA_SERVER}/${GITEA_REPO}.git" HEAD:main