Create how-optimized-data-curation-is-changing-the-game.mdx #5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Check ESLint for MDX Files | |
on: | |
pull_request_target: | |
paths: | |
- '**/*.mdx' | |
jobs: | |
eslint-mdx: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
ref: ${{ github.event.pull_request.head.ref }} | |
repository: ${{ github.event.pull_request.head.repo.full_name }} | |
- name: Set up Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '20.14.0' | |
- name: Install dependencies | |
run: | | |
npm install | |
- name: Install ESLint and plugins | |
run: | | |
npm install [email protected] eslint-plugin-mdx @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-jsx-a11y eslint-plugin-import --save-dev --legacy-peer-deps | |
- name: Configure ESLint | |
run: | | |
echo 'import js from "@eslint/js"; | |
import mdx from "eslint-plugin-mdx"; | |
import typescriptParser from "@typescript-eslint/parser"; | |
import typescriptPlugin from "@typescript-eslint/eslint-plugin"; | |
export default [ | |
js.configs.recommended, | |
{ | |
files: ["**/*.mdx"], | |
plugins: { | |
mdx, | |
"@typescript-eslint": typescriptPlugin, | |
}, | |
languageOptions: { | |
parser: typescriptParser, | |
}, | |
rules: { | |
...mdx.configs.recommended.rules, | |
...typescriptPlugin.configs.recommended.rules, | |
"react/prop-types": "off", | |
"@typescript-eslint/no-unused-vars": "error" | |
}, | |
}, | |
];' > eslint.config.js | |
- name: Get list of changed .mdx files | |
id: changed_files | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
echo "Fetching PR details..." | |
PR_NUMBER=$(jq -r .number < "$GITHUB_EVENT_PATH") | |
REPO_FULL_NAME=$(jq -r .pull_request.base.repo.full_name < "$GITHUB_EVENT_PATH") | |
echo "PR Number: $PR_NUMBER" | |
echo "Repository: $REPO_FULL_NAME" | |
RESPONSE=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \ | |
"https://api.github.com/repos/$REPO_FULL_NAME/pulls/$PR_NUMBER/files") | |
echo "GitHub API response: $RESPONSE" | |
CHANGED_FILES=$(echo "$RESPONSE" | jq -r '.[] | select(.filename | endswith(".mdx")) | .filename') | |
echo "CHANGED_FILES=$CHANGED_FILES" >> $GITHUB_ENV | |
echo "Changed files: $CHANGED_FILES" | |
- name: Run ESLint on changed .mdx files | |
id: eslint_check | |
env: | |
CHANGED_FILES: ${{ env.CHANGED_FILES }} | |
run: | | |
echo "Running ESLint" | |
if [ -z "$CHANGED_FILES" ]; then | |
echo "No .mdx files changed." | |
else | |
echo "Running ESLint with files: $CHANGED_FILES" | |
npx eslint $CHANGED_FILES | |
fi | |
- name: Print ESLint results | |
if: failure() | |
run: | | |
echo "ESLint check failed. See above for details." |