Skip to content

Commit

Permalink
Update eslint-mdx-check.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmIriarte authored Jul 24, 2024
1 parent 820c228 commit c45a62d
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion .github/workflows/eslint-mdx-check.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Check ESLint for MDX Files
name: Check and Fix ESLint for MDX Files

on:
pull_request_target:
Expand Down Expand Up @@ -87,6 +87,40 @@ jobs:
npx eslint $CHANGED_FILES --config eslint.config.mjs
fi
- name: Run ESLint with auto-fix
id: eslint_fix
env:
CHANGED_FILES: ${{ env.CHANGED_FILES }}
run: |
echo "Running ESLint with auto-fix"
if [ -z "$CHANGED_FILES" ]; then
echo "No .mdx files changed."
else
echo "Running ESLint with auto-fix on files: $CHANGED_FILES"
npx eslint $CHANGED_FILES --config eslint.config.mjs --fix
fi
- name: Check for changes
id: git_diff
run: |
if git diff --quiet; then
echo "No changes to commit"
echo "changes=false" >> $GITHUB_ENV
else
echo "Changes detected"
echo "changes=true" >> $GITHUB_ENV
- name: Commit and push changes
if: env.changes == 'true'
env:
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add .
git commit -m "Auto-fixed ESLint issues in MDX files"
git push "https://${GITHUB_TOKEN}@github.com/${{ github.repository }}" HEAD:${{ github.head_ref }}
- name: Print ESLint results
if: failure()
run: |
Expand Down

0 comments on commit c45a62d

Please sign in to comment.