Skip to content

Bump actions/upload-pages-artifact from 1 to 2 #275

Bump actions/upload-pages-artifact from 1 to 2

Bump actions/upload-pages-artifact from 1 to 2 #275

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/*
# Start the workflow
jobs:
permissions-check:
name: Permissions check
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' && github.actor != 'dependabot[bot]'
steps:
- name: ❓ Has access to secrets?
uses: actions/checkout@v3
with:
repository: ${{ github.event.repository.full_name }}
ref: ${{ github.head_ref }}
token: ${{ secrets.WORKFLOW_PAT }}
prechecks:
name: Pre-checks
runs-on: ubuntu-latest
needs: permissions-check
if: always() && !cancelled() && github.event_name == 'pull_request'
permissions:
contents: write
steps:
- name: 📂 Checkout
uses: actions/checkout@v3
with:
repository: ${{ github.event.repository.full_name }}
ref: ${{ github.head_ref }}
token: ${{ needs.permissions-check.result == 'failure' && github.token || secrets.WORKFLOW_PAT }}
- 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
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Update lock file
file_pattern: pnpm-lock.yaml
- name: 🔧 Check Inlang config
run: pnpm ci:update-inlang
- name: 📤 Commit updated Inlang config
id: auto-commit-action-inlang
if: needs.permissions-check.result != 'failure'
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Update Inlang config
file_pattern: inlang.config.js
- name: ❌ Exit if changes detected
if: needs.permissions-check.result != 'failure' && steps.auto-commit-action-lock.outputs.changes_detected == 'true' || steps.auto-commit-action-inlang.outputs.changes_detected == 'true'
run: exit 1
- name: ✨ Check Svelte format
run: pnpm check
- name: ✨ Check style with Prettier & ESLint
id: lint-check
run: pnpm ci:lint
- name: 🔧 Fix lint
if: failure() && needs.permissions-check.result != 'failure' && steps.lint-check.conclusion == 'failure'
run: pnpm format
- name: 📤 Commit lint fixes
if: failure() && needs.permissions-check.result != 'failure' && steps.lint-check.conclusion == 'failure'
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Fix lint
build:
name: Build website
runs-on: ubuntu-latest
needs: prechecks
if: always() && !cancelled() && (needs.prechecks.result == 'success' || needs.prechecks.result == 'skipped')
steps:
- name: 📂 Checkout
uses: actions/checkout@v3
with:
repository: ${{ github.event.repository.full_name }}
ref: ${{ github.head_ref }}
- 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 need for `--no-frozen-lockfile` here, as the sync is ensured by the `prechecks` job
- name: 🔨 Build repo
run: pnpm build
- name: 📤 Upload artifact
if: github.event_name != 'pull_request'
uses: actions/upload-pages-artifact@v2
with:
path: ./build
deploy:
name: Deploy website to GitHub Pages
runs-on: ubuntu-latest
needs: build
if: github.event_name != 'pull_request'
concurrency:
group: pages
cancel-in-progress: true
permissions:
pages: write
id-token: write
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:
name: Performance checks
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