mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-18 00:25:07 +00:00
ca3ab044c3
* Cache next.js build * Add format and lint job * Run typecheck * FIx all TS issues * Declare modules for images
116 lines
4.3 KiB
YAML
116 lines
4.3 KiB
YAML
on: [push]
|
|
name: CI
|
|
|
|
jobs:
|
|
deploy:
|
|
name: Deploy to Cloudflare Pages
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
deployments: write
|
|
outputs:
|
|
deployment_url: ${{ steps.cloudflare.outputs.url }}
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
- name: Setup bun
|
|
uses: oven-sh/setup-bun@v1
|
|
- name: Install dependencies
|
|
run: bun install --frozen-lockfile
|
|
- name: Cache Next.js build
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: |
|
|
${{ github.workspace }}/.next/cache
|
|
# Generate a new cache whenever packages or source files change.
|
|
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/bun.lockb') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
|
|
# If source files changed but packages didn't, rebuild from a prior cache.
|
|
restore-keys: |
|
|
${{ runner.os }}-nextjs-${{ hashFiles('**/bun.lockb') }}-
|
|
- name: Build Next.js with next-on-pages
|
|
run: bun run build:cloudflare
|
|
- id: cloudflare
|
|
name: Publish to Cloudflare Pages
|
|
uses: cloudflare/pages-action@v1
|
|
with:
|
|
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
|
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
|
projectName: ${{ vars.CLOUDFLARE_PROJECT_NAME }}
|
|
directory: ./.vercel/output/static
|
|
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
|
|
workingDirectory: ./
|
|
- name: Outputs
|
|
run: |
|
|
echo "ID: ${{ steps.cloudflare.outputs.id }}"
|
|
echo "URL: ${{ steps.cloudflare.outputs.url }}"
|
|
echo "Environment: ${{ steps.cloudflare.outputs.environment }}"
|
|
echo "Alias: ${{ steps.cloudflare.outputs.alias }}"
|
|
visual-testing:
|
|
runs-on: ubuntu-latest
|
|
name: Visual Testing
|
|
needs: deploy
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
- name: Setup bun
|
|
uses: oven-sh/setup-bun@v1
|
|
- name: Install dependencies
|
|
run: bun install --frozen-lockfile
|
|
- name: Run visual tests
|
|
run: bun ./tests/visual-testing.ts $DEPLOYMENT_URL
|
|
env:
|
|
DEPLOYMENT_URL: ${{needs.deploy.outputs.deployment_url}}
|
|
- name: Upload to Argos
|
|
run: bun x argos upload --token $ARGOS_TOKEN ./screenshots
|
|
env:
|
|
ARGOS_TOKEN: ${{ secrets.ARGOS_TOKEN }}
|
|
pagespeed-testing:
|
|
runs-on: ubuntu-latest
|
|
name: PageSpeed Testing
|
|
needs: deploy
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
- name: Setup bun
|
|
uses: oven-sh/setup-bun@v1
|
|
- name: Install dependencies
|
|
run: bun install --frozen-lockfile
|
|
- name: Run visual tests
|
|
run: bun ./tests/pagespeed-testing.ts $DEPLOYMENT_URL
|
|
env:
|
|
DEPLOYMENT_URL: ${{needs.deploy.outputs.deployment_url}}
|
|
PAGESPEED_API_KEY: ${{ secrets.PAGESPEED_API_KEY }}
|
|
format:
|
|
runs-on: ubuntu-latest
|
|
name: Format
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
- name: Setup bun
|
|
uses: oven-sh/setup-bun@v1
|
|
- name: Install dependencies
|
|
run: bun install --frozen-lockfile
|
|
- run: bun format --check .
|
|
lint:
|
|
runs-on: ubuntu-latest
|
|
name: Lint
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
- name: Setup bun
|
|
uses: oven-sh/setup-bun@v1
|
|
- name: Install dependencies
|
|
run: bun install --frozen-lockfile
|
|
- run: bun lint
|
|
typecheck:
|
|
runs-on: ubuntu-latest
|
|
name: Typecheck
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
- name: Setup bun
|
|
uses: oven-sh/setup-bun@v1
|
|
- name: Install dependencies
|
|
run: bun install --frozen-lockfile
|
|
- run: bun typecheck
|