-
Notifications
You must be signed in to change notification settings - Fork 1
41 lines (41 loc) · 1.35 KB
/
treefmt.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
name: Format Code
on:
push:
workflow_dispatch:
jobs:
format:
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- uses: ahmadnassri/action-workflow-queue@v1
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/flakehub-cache-action@main
- name: Install formatting tools
run: nix-env -f "<nixpkgs>" -iA nixfmt-rfc-style treefmt yamlfmt jsonfmt markdownlint-cli
- name: Add new branch
run: git checkout -b treefmt-code
- name: Run treefmt
uses: isbecker/treefmt-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
version: "latest"
fail_on_change: "false"
- name: Commit changes
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
if ! git diff --quiet; then
git pull
git add .
git commit -m "refactor(*): automated formatting"
fi
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref_name }}