Skip to content

Commit

Permalink
ci: split format job
Browse files Browse the repository at this point in the history
  • Loading branch information
getchoo committed Nov 27, 2024
1 parent 645cd89 commit 9d86b66
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 37 deletions.
37 changes: 0 additions & 37 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,43 +13,6 @@ on:
workflow_dispatch:

jobs:
format:
name: Format Nix files

if: github.repository_owner == 'Catppuccin' && github.event_name == 'push' || github.event_name == 'workflow_dispatch'

runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.PUSH_TOKEN }}

- name: Set Git user info
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
- name: Get short revision
id: rev
run:
echo "rev=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"

- name: Install Nix
uses: cachix/install-nix-action@V27

- name: Format changes
run: |
nix fmt
- name: Commit changes
run: |
if ! git diff --color=always --exit-code; then
git commit -am "style: format ${{ steps.rev.outputs.rev }}"
git push
fi
test:
name: Test Modules

Expand Down
45 changes: 45 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Format

on:
push:
branches: [ main ]
paths:
- "**.nix"
- ".github/workflows/format.yml"
workflow_dispatch:

jobs:
nix:
name: Nix files

runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.PUSH_TOKEN }}

- name: Set Git user info
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
- name: Get short revision
id: rev
run:
echo "rev=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"

- name: Install Nix
uses: cachix/install-nix-action@V27

- name: Format changes
run: |
nix fmt
- name: Commit changes
run: |
if ! git diff --color=always --exit-code; then
git commit -am "style: format ${{ steps.rev.outputs.rev }}"
git push
fi

0 comments on commit 9d86b66

Please sign in to comment.