initial commit after project creation
This commit is contained in:
127
.github/workflows/build-and-deploy.yml
vendored
Normal file
127
.github/workflows/build-and-deploy.yml
vendored
Normal file
@@ -0,0 +1,127 @@
|
||||
# Sample workflow for building and deploying a Next.js site to GitHub Pages
|
||||
#
|
||||
# To get started with Next.js see: https://nextjs.org/docs/getting-started
|
||||
#
|
||||
name: Deploy Next.js site to Pages
|
||||
|
||||
on:
|
||||
# Runs on pushes targeting the default branch
|
||||
push:
|
||||
branches: [main]
|
||||
|
||||
# Allows you to run this workflow manually from the Actions tab
|
||||
workflow_dispatch:
|
||||
|
||||
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
|
||||
permissions:
|
||||
contents: read
|
||||
pages: write
|
||||
id-token: write
|
||||
|
||||
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
|
||||
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
|
||||
concurrency:
|
||||
group: "pages"
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
# Build job
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Detect package manager
|
||||
id: detect-package-manager
|
||||
run: |
|
||||
if [ -f "${{ github.workspace }}/yarn.lock" ]; then
|
||||
echo "✅ Detected yarn"
|
||||
echo "manager=yarn" >> $GITHUB_OUTPUT
|
||||
echo "command=install" >> $GITHUB_OUTPUT
|
||||
echo "runner=yarn" >> $GITHUB_OUTPUT
|
||||
exit 0
|
||||
elif [ -f "${{ github.workspace }}/pnpm-lock.yaml" ]; then
|
||||
echo "✅ Detected pnpm"
|
||||
echo "manager=pnpm" >> $GITHUB_OUTPUT
|
||||
echo "command=install" >> $GITHUB_OUTPUT
|
||||
echo "runner=pnpm" >> $GITHUB_OUTPUT
|
||||
exit 0
|
||||
elif [ -f "${{ github.workspace }}/package.json" ]; then
|
||||
echo "✅ Detected npm"
|
||||
echo "manager=npm" >> $GITHUB_OUTPUT
|
||||
echo "command=ci" >> $GITHUB_OUTPUT
|
||||
echo "runner=npx --no-install" >> $GITHUB_OUTPUT
|
||||
exit 0
|
||||
else
|
||||
echo "❌ Unable to determine package manager"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Setup pnpm
|
||||
if: steps.detect-package-manager.outputs.manager == 'pnpm'
|
||||
uses: pnpm/action-setup@v4
|
||||
with:
|
||||
version: 9.15.2
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version-file: .nvmrc
|
||||
cache: ${{ steps.detect-package-manager.outputs.manager }}
|
||||
|
||||
- name: "Setup Pages #1"
|
||||
run: |
|
||||
touch public/.nojekyll
|
||||
- name: "Setup Pages #2"
|
||||
uses: actions/configure-pages@v5
|
||||
with:
|
||||
# Automatically inject basePath in your Next.js configuration file and disable
|
||||
# server side image optimization (https://nextjs.org/docs/api-reference/next/image#unoptimized).
|
||||
#
|
||||
# You may remove this line if you want to manage the configuration yourself.
|
||||
static_site_generator: next
|
||||
|
||||
- name: Restore cache
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
.next/cache
|
||||
# Generate a new cache whenever packages or source files change.
|
||||
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/pnpm-lock.yaml', '**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
|
||||
# If source files changed but packages didn't, rebuild from a prior cache.
|
||||
restore-keys: |
|
||||
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/pnpm-lock.yaml', '**/yarn.lock') }}-
|
||||
|
||||
- name: Install dependencies
|
||||
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
|
||||
|
||||
- name: Build with Next.js & TinaCMS
|
||||
run: ${{ steps.detect-package-manager.outputs.runner }} export
|
||||
env:
|
||||
NEXT_PUBLIC_TINA_CLIENT_ID: ${{ secrets.NEXT_PUBLIC_TINA_CLIENT_ID }}
|
||||
NEXT_PUBLIC_TINA_BRANCH: ${{ github.ref_name }}
|
||||
TINA_TOKEN: ${{ secrets.TINA_TOKEN }}
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-pages-artifact@v3
|
||||
with:
|
||||
path: ./.next
|
||||
|
||||
search-tests:
|
||||
needs: build
|
||||
uses: ./.github/workflows/search-test.yml
|
||||
with:
|
||||
base_url: https://tina-docs-red.vercel.app/
|
||||
|
||||
# Deployment job
|
||||
deploy:
|
||||
environment:
|
||||
name: github-pages
|
||||
url: ${{ steps.deployment.outputs.page_url }}
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
steps:
|
||||
- name: Deploy to GitHub Pages
|
||||
id: deployment
|
||||
uses: actions/deploy-pages@v4
|
||||
29
.github/workflows/lint.yml
vendored
Normal file
29
.github/workflows/lint.yml
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
name: Lint and Check
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
lint-and-check:
|
||||
name: Run Biome Lint and Check
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version-file: ".nvmrc"
|
||||
|
||||
- name: Enable Corepack
|
||||
run: corepack enable
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: Run Biome Lint & Formatter
|
||||
run: pnpm lint src/ tina/
|
||||
|
||||
76
.github/workflows/pr-open.yml
vendored
Normal file
76
.github/workflows/pr-open.yml
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
name: Build Pull request
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened]
|
||||
env:
|
||||
NEXT_PUBLIC_TINA_CLIENT_ID: ${{ secrets.NEXT_PUBLIC_TINA_CLIENT_ID }}
|
||||
TINA_TOKEN: ${{ secrets.TINA_TOKEN }}
|
||||
NEXT_PUBLIC_TINA_BRANCH: ${{ github.head_ref }}
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
name: Build sample
|
||||
outputs:
|
||||
NEXT_PUBLIC_BASE_PATH: ${{ steps.setup-base-path.outputs.NEXT_PUBLIC_BASE_PATH }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version-file: .nvmrc
|
||||
|
||||
- uses: pnpm/action-setup@v4
|
||||
name: Install pnpm
|
||||
id: pnpm-install
|
||||
with:
|
||||
version: 9.15.2
|
||||
run_install: false
|
||||
|
||||
- name: Get pnpm store directory
|
||||
id: pnpm-cache
|
||||
shell: bash
|
||||
run: |
|
||||
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
|
||||
|
||||
- uses: actions/cache@v4
|
||||
name: Setup pnpm cache
|
||||
with:
|
||||
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
|
||||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pnpm-store-
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install
|
||||
|
||||
- name: Load .env file
|
||||
uses: xom9ikk/dotenv@v2
|
||||
with:
|
||||
path: ./.github
|
||||
|
||||
- name: Setup Base Path
|
||||
id: setup-base-path
|
||||
run: |
|
||||
echo "NEXT_PUBLIC_BASE_PATH=${{ env.NEXT_PUBLIC_BASE_PATH }}" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Build
|
||||
run: pnpm build
|
||||
|
||||
slugify-branch:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
slug: ${{ steps.slug.outputs.slug }}
|
||||
steps:
|
||||
- name: Slugify branch name
|
||||
id: slug
|
||||
run: |
|
||||
SLUG=$(echo "${{ github.head_ref }}" | tr '/' '-' | tr -d '.' | tr '[:upper:]' '[:lower:]')
|
||||
echo "slug=$SLUG" >> $GITHUB_OUTPUT
|
||||
|
||||
search-tests:
|
||||
needs: [build, slugify-branch]
|
||||
uses: ./.github/workflows/search-test.yml
|
||||
with:
|
||||
base_url: https://tina-docs-git-${{ needs.slugify-branch.outputs.slug }}-tinacms.vercel.app
|
||||
NEXT_PUBLIC_BASE_PATH: ${{ needs.build.outputs.NEXT_PUBLIC_BASE_PATH }}
|
||||
89
.github/workflows/search-test.yml
vendored
Normal file
89
.github/workflows/search-test.yml
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
name: Search Functionality Tests
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
base_url:
|
||||
description: 'Base URL to test (required)'
|
||||
required: true
|
||||
type: string
|
||||
workflow_call:
|
||||
inputs:
|
||||
base_url:
|
||||
description: 'Base URL to test (required)'
|
||||
required: true
|
||||
type: string
|
||||
NEXT_PUBLIC_BASE_PATH:
|
||||
description: 'Base path (required)'
|
||||
required: true
|
||||
type: string
|
||||
|
||||
jobs:
|
||||
test-search:
|
||||
name: Test Search Functionality
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
with:
|
||||
version: 9.15.2
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version-file: .nvmrc
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install
|
||||
|
||||
- name: Install Playwright browsers
|
||||
run: npx playwright install --with-deps
|
||||
|
||||
- name: Run search tests
|
||||
run: pnpm test
|
||||
env:
|
||||
BASE_URL: ${{ inputs.base_url }}
|
||||
NEXT_PUBLIC_BASE_PATH: ${{ inputs.NEXT_PUBLIC_BASE_PATH || '' }}
|
||||
|
||||
- name: Upload test results
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: test-results
|
||||
path: |
|
||||
test-results/
|
||||
playwright-report/
|
||||
retention-days: 7
|
||||
|
||||
report-results:
|
||||
name: Report Test Results
|
||||
runs-on: ubuntu-latest
|
||||
needs: [test-search]
|
||||
if: always()
|
||||
|
||||
steps:
|
||||
- name: Download test results
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: test-results/
|
||||
|
||||
- name: Create test summary
|
||||
run: |
|
||||
echo "## Search Functionality Test Results" >> $GITHUB_STEP_SUMMARY
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
|
||||
if [ -f "test-results/test-results/test-results/results.json" ]; then
|
||||
echo "### Search Tests ✅" >> $GITHUB_STEP_SUMMARY
|
||||
echo "Search tests completed successfully." >> $GITHUB_STEP_SUMMARY
|
||||
else
|
||||
echo "### Search Tests ❌" >> $GITHUB_STEP_SUMMARY
|
||||
echo "Search tests failed or were not run." >> $GITHUB_STEP_SUMMARY
|
||||
fi
|
||||
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "Check the artifacts for detailed test reports." >> $GITHUB_STEP_SUMMARY
|
||||
Reference in New Issue
Block a user