Skip to content

ci: do not try to deploy the playground from main #415

ci: do not try to deploy the playground from main

ci: do not try to deploy the playground from main #415

Workflow file for this run

name: CI
on:
push:
branches: [main] # Run tests/lint/build on pushes to main
pull_request: # Run tests/lint/build on PRs
types: [opened, reopened, synchronize]
branches-ignore:
- "**/graphite-base/**"
release:
types: [published] # Trigger publish job when a GitHub release is published
workflow_dispatch: # Allow manual runs
permissions:
contents: read
# Required for npm OICD (https://docs.npmjs.com/trusted-publishers)
id-token: write
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 22
registry-url: "https://registry.npmjs.org/"
- run: pnpm install
- run: pnpm lint
- run: pnpm test
- run: pnpm build
publish-npm:
needs: build-and-test
runs-on: ubuntu-latest
if: github.event_name == 'release'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
registry-url: "https://registry.npmjs.org/"
- uses: pnpm/action-setup@v4
- name: Re-install npm
# TODO: OIDC requires npm >=11.5.1.
# Until Node.js v24 is LTS (with npm 11 as the default), we need to bump.
run: npm install -g npm@11
- run: pnpm install
- run: pnpm build
- name: Publish to npm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
# Extract version from package.json
VERSION=$(node -p "require('./package.json').version")
# Check if it's a prerelease version (contains a hyphen, e.g., 3.0.0-alpha.0)
if [[ "$VERSION" == *-* ]]; then
# Extract the prerelease tag (e.g., "alpha" from "3.0.0-alpha.0")
PRERELEASE_TAG=$(echo "$VERSION" | sed 's/.*-\([a-zA-Z]*\).*/\1/')
echo "Publishing prerelease version $VERSION with tag: $PRERELEASE_TAG"
pnpm publish --access public --tag "$PRERELEASE_TAG" --no-git-checks
else
echo "Publishing stable version $VERSION"
pnpm publish --access public --no-git-checks
fi
deploy-docs:
needs: build-and-test
runs-on: ubuntu-latest
if: github.event_name == 'release'
steps:
- uses: actions/checkout@v4
with:
ref: main
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: "pnpm"
- name: Install dependencies (main branch)
run: pnpm install
- name: Build v2 docs from main branch
run: pnpm docs:build
- name: Move v2 docs to combined folder
run: |
mkdir -p combined/v2
mv docs/.vitepress/dist/* combined/v2/
- name: Checkout release tag
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
clean: false
- name: Install dependencies (release tag)
run: pnpm install
- name: Build and move v3 docs if v3 release
run: |
TAG_NAME="${{ github.ref_name }}"
if [[ "$TAG_NAME" == v3* ]]; then
pnpm docs:build
mkdir -p combined/v3
mv docs/.vitepress/dist/* combined/v3/
fi
- name: Copy v2 docs to root for default access
run: cp -r combined/v2/* combined/
- name: Deploy docs to production server
uses: easingthemes/ssh-deploy@main
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
REMOTE_HOST: ${{ secrets.SSH_HOST }}
REMOTE_USER: ${{ secrets.SSH_USER }}
REMOTE_PORT: ${{ secrets.SSH_PORT }}
SOURCE: "combined/."
TARGET: ${{ secrets.TARGET_DIR_DOCS }}
deploy-playground:
needs: build-and-test
runs-on: ubuntu-latest
if: (github.event_name == 'release' || github.event_name == 'workflow_dispatch') && github.ref != 'refs/heads/main'
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: "pnpm"
- name: Install and build parent package
run: |
pnpm install
pnpm build
- name: Install playground dependencies
working-directory: playground
run: pnpm install
- name: Build playground in static mode
working-directory: playground
env:
NUXT_APP_BASE_URL: ${{ secrets.PLAYGROUND_BASE_URL }}
run: pnpm generate
- name: Deploy playground to production server
uses: easingthemes/ssh-deploy@main
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
REMOTE_HOST: ${{ secrets.SSH_HOST }}
REMOTE_USER: ${{ secrets.SSH_USER }}
REMOTE_PORT: ${{ secrets.SSH_PORT }}
SOURCE: "playground/.output/public/."
TARGET: ${{ secrets.TARGET_DIR_PLAYGROUND }}