48 lines
1.3 KiB
YAML
48 lines
1.3 KiB
YAML
name: format
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
ci_mode:
|
|
description: 'Run treefmt with --ci (fail if changes needed)'
|
|
type: boolean
|
|
required: false
|
|
default: true
|
|
commit_changes:
|
|
description: 'Commit changes if formatting is needed (only if ci_mode is false)'
|
|
type: boolean
|
|
required: false
|
|
default: false
|
|
|
|
jobs:
|
|
treefmt:
|
|
timeout-minutes: 15
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
steps:
|
|
- name: checkout code
|
|
uses: actions/checkout@v4
|
|
- name: install nix
|
|
uses: cachix/install-nix-action@v31.6.1
|
|
with:
|
|
nix_path: nixpkgs=channel:nixos-unstable
|
|
- uses: cachix/cachix-action@v16
|
|
with:
|
|
name: nix-community
|
|
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
|
|
- name: treefmt
|
|
run: |
|
|
if [ "${{ inputs.ci_mode }}" = "true" ]; then
|
|
nix fmt -- --ci
|
|
else
|
|
nix fmt
|
|
fi
|
|
- name: commit changes
|
|
if: ${{ inputs.ci_mode == 'false' && inputs.commit_changes == 'true' }}
|
|
uses: stefanzweifel/git-auto-commit-action@v6.0.1
|
|
with:
|
|
commit_message: |
|
|
style: autoformatting all ${{ inputs.language }} files
|
|
|
|
[skip ci]
|