fix: SEO, performance, minor bugs #9
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: ๐จ Code Lint and Format | |
on: | |
pull_request: | |
types: [opened, synchronize] | |
concurrency: | |
group: code-lint-format | |
cancel-in-progress: true | |
jobs: | |
build-and-deploy: | |
name: ๐ ๏ธ Code linter and formatter | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
pull-requests: write | |
issues: write | |
steps: | |
- name: ๐ฅ Checkout Code | |
uses: actions/checkout@v4 | |
- uses: pnpm/action-setup@v4 | |
name: ๐ ๏ธ Install pnpm | |
with: | |
run_install: false | |
- name: ๐ ๏ธ Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 'lts/*' | |
cache: 'pnpm' | |
- name: ๐๏ธ Get pnpm store directory | |
shell: bash | |
run: | | |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
- uses: actions/cache@v4 | |
name: โก Setup pnpm cache | |
with: | |
path: ${{ env.STORE_PATH }} | |
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm-store- | |
- name: ๐ Install dependencies | |
run: pnpm install | |
- name: ๐จ Lint Code | |
run: pnpm lint:fix | tee lint-results.txt | |
- name: ๐จ Format Code | |
run: pnpm format | tee prettier-results.txt | |
- name: ๐ฎ Clean up results | |
run: | | |
sed -i 's/\x1b\[[0-9;]*m//g' prettier-results.txt | |
sed -i 's/\x1b\[[0-9;]*m//g' lint-results.txt | |
- name: ๐ Format all results | |
run: | | |
{ | |
echo "### ๐จ Prettier Format Check" | |
echo "" | |
if grep -q "(changed)" prettier-results.txt; then | |
echo "โ ๏ธ **Prettier Issues Found** - Some format issues are fixed automatically by Prettier:" | |
echo '```' | |
grep -E "\s+\(changed\)" prettier-results.txt || true | |
echo '```' | |
else | |
echo "โ **Prettier**: No formatting issues found!" | |
fi | |
echo "" | |
echo "### ๐จ Lint Check" | |
echo "" | |
if grep -qE "^[^0]* problems" lint-results.txt; then | |
echo "โ ๏ธ **Lint Issues Found** - PLEASE FIX THEM!" | |
echo '```' | |
cat lint-results.txt | |
echo '```' | |
else | |
echo "โ **Lint**: No linting issues found!" | |
fi | |
} > formatted-results.txt | |
- name: ๐ฌ Post test results and preview link to PR | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const fs = require('fs'); | |
const testResults = fs.readFileSync('formatted-results.txt', 'utf8'); | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: `${testResults}` | |
}); |