Feat/optimized ci #897
This file contains hidden or 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: CI | |
| on: | |
| push: | |
| branches: [feat/optimized-ci] | |
| pull_request: | |
| branches: [beta] | |
| permissions: | |
| contents: read | |
| jobs: | |
| lint: | |
| name: Lint & Format | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Check set:html safety | |
| run: | | |
| if grep -r "set:html" src --include="*.astro" | grep -Ev "set:html=\{(safeMarkdown\.|DOMPurify\.sanitize)"; then | |
| echo "Error: Found set:html usage without safeMarkdown or DOMPurify.sanitize" | |
| exit 1 | |
| fi | |
| echo "All set:html usages are safe" | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: "22" | |
| cache: "pnpm" | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: ESLint - TypeScript validity | |
| run: pnpm lint | |
| - name: Stylelint - CSS compatibility | |
| run: pnpm lint:css | |
| - name: Prettier - Code formatting | |
| run: pnpm format:check | |
| - name: Type check | |
| run: pnpm check | |
| build: | |
| name: Build & Validate | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: "22" | |
| cache: "pnpm" | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Determine base SHA | |
| id: base | |
| run: | | |
| if [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]]; then | |
| # diff all files in the PR | |
| echo "DEBUG: pull requesy" | |
| git fetch origin $GITHUB_BASE_REF | |
| BASE_SHA=$(git merge-base HEAD origin/$GITHUB_BASE_REF) | |
| else | |
| # diff only the latest commit | |
| echo "DEBUG: push" | |
| BASE_SHA=$(git rev-parse HEAD^) | |
| fi | |
| echo "BASE_SHA=$BASE_SHA" >> $GITHUB_ENV | |
| echo "Using BASE_SHA=$BASE_SHA" | |
| - name: Prepare source for CI build | |
| run: >- | |
| pnpm prepare-ci | |
| --limit-posts 10 | |
| --skip-og | |
| --limit-locales | |
| --base-sha "${{ github.event.pull_request.base.sha || github.event.before }}" | |
| - name: Build site | |
| env: | |
| SKIP_IMAGE_OPTIMIZATION: "true" | |
| run: pnpm build | |
| - name: Validate built HTML | |
| run: pnpm exec htmlhint 'dist/**/*.html' |