name: Check Code with Prettier on: pull_request: branches: - 'master' jobs: format: runs-on: ubuntu-latest steps: - name: Check out repo uses: actions/checkout@v3 - name: Setup node uses: actions/setup-node@v3 with: node-version: 18 cache: 'npm' - name: Download dependencies run: npm ci - name: Run prettier run: |- npx prettier -c 'apps/**/*.{js,jsx,ts,tsx,css,md,mdx,json}' # [Joshen] Temp disable the following due to an issue # https://github.com/EPMatt/reviewdog-action-prettier/issues/34 # uses: EPMatt/reviewdog-action-prettier@v1 # with: # github_token: ${{ secrets.github_token }} # reporter: github-pr-review # level: warning # command: npx prettier -c 'apps/**/*.{js,jsx,ts,tsx,css,md,json}' # run: |- # function run_check() { # if $(grep -q '"prettier"' "$1") ; then # pushd "$(dirname $1)" # echo "Running prettier on $(pwd)" # npx prettier -c '**/*.{js,jsx,ts,tsx,css,md,json}' # popd # fi # } # find . -type f -name 'package.json' ! -path '*node_modules*' -print0 | while IFS= read -r -d '' file; do # run_check "$file" # done # i18n is not a node package, so we handle that one separately format-i18n: runs-on: ubuntu-latest steps: - name: Check out repo uses: actions/checkout@v3 - name: Setup node uses: actions/setup-node@v3 with: node-version: 18 cache: 'npm' - name: Download dependencies run: npm ci - name: Run prettier run: |- npx prettier -c 'i18n/**/*.{js,jsx,ts,tsx,css,md,mdx,json}' # uses: EPMatt/reviewdog-action-prettier@v1 # with: # github_token: ${{ secrets.github_token }} # reporter: github-pr-review # level: warning # command: npx prettier -c 'i18n/**/*.{js,jsx,ts,tsx,css,md,json}' format-sql: runs-on: ubuntu-latest steps: - name: Check out repo uses: actions/checkout@v3 - name: Install plugin run: npm ci - name: Run prettier run: |- # Check mdx files which contain sql code blocks grep -lr '```sql' apps/docs/pages/**/*.mdx | xargs npx prettier -c