Skip to content

Bump ws from 7.5.9 to 7.5.10 in the npm_and_yarn group across 1 directory #39

Bump ws from 7.5.9 to 7.5.10 in the npm_and_yarn group across 1 directory

Bump ws from 7.5.9 to 7.5.10 in the npm_and_yarn group across 1 directory #39

name: ESLint and Prettier Check
on:
pull_request:
types: [opened, synchronize, reopened]
branches:
- dev
jobs:
lint_and_format:
name: Check Lint and Format
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }} # This makes sure we're checking out the head of the branch involved in the PR
fetch-depth: 0 # Important to fetch all history for commits comparison
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'npm'
- name: Install Dependencies
run: npm ci
- name: Run ESLint and Prettier for Code Formatting
run: npm run lint-and-format
# This command must exit with a non-zero status if there are errors that cannot be auto-fixed
- name: Check for Modified Files
id: git-check
run: |
if [[ `git status --porcelain` ]]; then
echo "changes_detected=true" >> $GITHUB_ENV
fi
- name: Avoid recursive workflow runs
run: |
if git log -1 --pretty=%B | grep -q 'Apply ESLint and Prettier fixes generated by GitHub Actions'; then
echo "Recursive commit detected - exiting!"
exit 0
fi
- name: Commit and Push Changes if needed
if: env.changes_detected == 'true'
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git add .
git restore --staged .github/
if git diff --cached --quiet; then
echo "No changes to commit after filtering out workflow changes."
else
git commit -m "Apply ESLint and Prettier fixes generated by GitHub Actions"
git push origin ${{ github.head_ref }} --force
fi
env:
GITHUB_TOKEN: ${{ secrets.FINE_GRAINED_PAT }} # Using the PAT instead of GITHUB_TOKEN
- name: Log Results
run: |
if [ "${{ job.status }}" == "success" ]; then
echo "ESLint checks completed successfully."
echo "Prettier formatting check completed successfully."
echo "All checks have passed successfully."
else
echo "Some checks have failed. Please review the annotations."
exit 1 # This ensures that the step explicitly fails if previous steps had issues.
fi