Stricter TypeScript #224
Workflow file for this run
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
# Based on https://gist.github.com/AndrewLester/2d3e6257d932831756226ca9a281d9b5 | |
name: Build and Deploy to Pages | |
on: | |
push: | |
branches: | |
- "main" | |
paths: | |
- "src/**" | |
- "static/**" | |
- "package.json" | |
- "pnpm-lock.yaml" | |
- "*.config.*s" | |
- "tsconfig.json" | |
- ".github/workflows/*" | |
pull_request: | |
paths: | |
- "src/**" | |
- "static/**" | |
- "package.json" | |
- "pnpm-lock.yaml" | |
- "*.config.*s" | |
- "tsconfig.json" | |
- ".github/workflows/*" | |
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
# Allow one concurrent deployment | |
concurrency: | |
group: "pages" | |
cancel-in-progress: true | |
# Start the workflow | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: π Checkout | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.head_ref }} | |
token: ${{ secrets.WORKFLOW_PAT }} | |
- name: π§ Configure pages | |
uses: actions/configure-pages@v3 | |
if: github.event_name != 'pull_request' | |
id: pages | |
with: | |
static_site_generator: "sveltekit" | |
- name: π₯ Install pnpm | |
uses: pnpm/action-setup@v2 | |
with: | |
version: latest | |
- name: π§ Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: latest | |
cache: "pnpm" | |
- name: π₯ Install NPM dependencies | |
run: pnpm i --no-frozen-lockfile | |
- name: π€ Commit updated lock file | |
id: auto-commit-action-lock | |
if: github.event_name == 'pull_request' | |
uses: stefanzweifel/git-auto-commit-action@v4 | |
with: | |
commit_message: "Update lock file" | |
file_pattern: "pnpm-lock.yaml" # Should not be needed, but still | |
- name: π§ Check Inlang config | |
run: pnpm ci:update-inlang | |
- name: π€ Commit updated Inlang config | |
id: auto-commit-action-inlang | |
if: github.event_name == 'pull_request' | |
uses: stefanzweifel/git-auto-commit-action@v4 | |
with: | |
commit_message: "Update Inlang config" | |
file_pattern: "inlang.config.js" # Should not be needed, but still | |
- name: β Exit if changes detected | |
if: steps.auto-commit-action-lock.outputs.changes_detected == 'true' || steps.auto-commit-action-inlang.outputs.changes_detected == 'true' | |
run: exit 1 | |
- name: π± Create .env file | |
run: echo ${{ secrets.ENV }} > .env | |
- name: β¨ Check Svelte format | |
run: pnpm check | |
- name: β¨ Check style with Prettier & ESLint | |
id: lint-check | |
run: pnpm ci:lint | |
# These steps will only ever trigger on PRs because merge is not allowed on failure | |
- name: π§ Fix lint (if needed) | |
if: ${{ failure() && steps.lint-check.conclusion == 'failure' }} | |
run: | | |
git reset --hard | |
pnpm format | |
- name: π€ Commit lint fixes (if needed) | |
if: ${{ failure() && steps.lint-check.conclusion == 'failure' }} | |
uses: stefanzweifel/git-auto-commit-action@v4 | |
with: | |
commit_message: "Fix lint" | |
# These steps won't run on previous errors (by default) | |
- name: π¨ Build repo | |
run: pnpm build | |
- name: π€ Upload artifact | |
if: github.event_name != 'pull_request' | |
uses: actions/upload-pages-artifact@v1 | |
with: | |
path: ./build | |
deploy: | |
runs-on: ubuntu-latest | |
if: github.event_name != 'pull_request' | |
needs: build | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
outputs: | |
page_url: ${{ steps.deployment.outputs.page_url }} | |
steps: | |
- name: π Deploy Pages | |
uses: actions/deploy-pages@v2 | |
id: deployment | |
perf-check: | |
runs-on: ubuntu-latest | |
needs: deploy | |
steps: | |
- name: βοΈ Unlighthouse check | |
run: | | |
npm i -g @unlighthouse/cli puppeteer | |
unlighthouse-ci --site ${{ needs.deploy.outputs.page_url }} --budget 75 | |
- name: π€ Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: unlighthouse-result | |
path: .unlighthouse/ci-result.json |