Skip to content

Migrate to Svelte 4 #207

Migrate to Svelte 4

Migrate to Svelte 4 #207

Workflow file for this run

# 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