Skip to content

refactor(tasks/boards): modularize enhanced-boards-view into focused … #1951

refactor(tasks/boards): modularize enhanced-boards-view into focused …

refactor(tasks/boards): modularize enhanced-boards-view into focused … #1951

name: Prettier Format Check
on:
push:
branches-ignore:
- 'dependabot/**'
- 'staging'
- 'production'
workflow_dispatch:
jobs:
format:
name: Prettier Check
timeout-minutes: 10
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
strategy:
matrix:
node-version: [23]
steps:
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 2
# Required for creating commits and PRs
token: ${{ secrets.GITHUB_TOKEN }}
- name: Cache turbo build setup
uses: actions/cache@v4
with:
path: .turbo
key: ${{ runner.os }}-turbo-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-
- uses: oven-sh/setup-bun@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: bun install
- name: Check Prettier formatting
id: check-format
run: bun format:check || echo "format_failed=true" >> $GITHUB_OUTPUT
- name: Apply Prettier fixes
if: steps.check-format.outputs.format_failed == 'true'
run: bun format
- name: Check for changes
if: steps.check-format.outputs.format_failed == 'true'
id: git-check
run: |
if [[ -n $(git status --porcelain) ]]; then
echo "changes=true" >> $GITHUB_OUTPUT
else
echo "changes=false" >> $GITHUB_OUTPUT
fi
- name: Configure Git
if: steps.git-check.outputs.changes == 'true'
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
- name: Create Pull Request
if: steps.git-check.outputs.changes == 'true'
id: create-pr
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: 'style: apply prettier formatting'
title: 'style: apply prettier formatting for ${{ github.ref_name }}'
body: |
This PR fixes code formatting issues using Prettier.
Auto-generated by the Prettier Format Check workflow.
branch: fix/prettier-formatting-${{ github.ref_name }}
base: ${{ github.ref_name }}
delete-branch: true
- name: Fail Workflow After Creating PR
if: steps.create-pr.outputs.pull-request-number != ''
run: |
echo "Prettier formatting issues were found and a PR has been created."
echo "PR: ${{ steps.create-pr.outputs.pull-request-url }}"
exit 1
- name: Comment on PR
if: github.event_name == 'pull_request' && steps.check-format.outputs.format_failed == 'true'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '❌ Prettier format check failed. Please run `bun format` locally and commit the changes.'
})