Skip to content

Daily Prettier Linting #3

Daily Prettier Linting

Daily Prettier Linting #3

name: Daily Prettier Linting
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
jobs:
prettier:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Clear Yarn cache
run: yarn cache clean
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18.16.0'
cache: 'yarn'
- name: Install dependencies
run: yarn install --immutable
- name: Build Packages
shell: bash
run: yarn build
- name: Format Code with Prettier
run: yarn format
- name: Check for Changes
id: git-check
run: |
echo "Diff output:"
git diff
CHANGED=$(git diff --name-only | wc -l)
echo "Number of changed files: $CHANGED"
echo "changed=$CHANGED" >> $GITHUB_OUTPUT
- name: Commit Component Count
if: steps.git-check.outputs.changed != '0'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git remote set-url origin "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git"
git add .
git commit -m "chore: format code with Prettier [skip ci]" || echo "No changes to commit"
- name: Push Changes to Branch
if: steps.git-check.outputs.changed != '0'
run: git push origin HEAD:prettier-fix-${{ github.run_id }}
- name: Create Pull Request
if: steps.git-check.outputs.changed != '0'
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: 'chore: format code with Prettier [skip ci]'
title: 'chore: format code with Prettier'
body: |
This PR applies automatic formatting changes using Prettier to maintain code consistency.
base: candidate
branch: prettier-fix-${{ github.run_id }}
labels: formatting