Skip to content

Commit

Permalink
chore: fix publish
Browse files Browse the repository at this point in the history
Signed-off-by: Newton <5769156+iamnewton@users.noreply.github.com>
  • Loading branch information
iamnewton committed Nov 8, 2024
1 parent c63a4cf commit b67267a
Showing 1 changed file with 49 additions and 38 deletions.
87 changes: 49 additions & 38 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,86 +1,97 @@
name: Deploy

on: # yamllint disable-line rule:truthy
on:
push:
branches:
- main

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# 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

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

jobs:
github-pages:
name: Deploy Storybook to GitHub Pages
runs-on: ubuntu-latest
steps:
- uses: bitovi/github-actions-storybook-to-github-pages@v1.0.3
id: deploy-github-pages
name: Deploy Storybook to GitHub Pages
with:
build_command: npm run build:storybook
install_command: npm ci
path: docs
environment:
name: github-pages
url: ${{ steps.deploy-github-pages.outputs.page_url }}

nextjs:
name: Deploy Next.js site to Pages
deploy:
name: Deploy Storybook and Next.js site to GitHub Pages
runs-on: ubuntu-latest
steps:
# Checkout the repository
- uses: actions/checkout@v4
name: Checkout repository

# Setup Node.js
- uses: actions/setup-node@v4
name: Setup Node.js @v20
with:
cache: npm
node-version: 20.x

# ---------------------
# 1. Deploy Storybook
# ---------------------
- name: Install dependencies for Storybook
run: npm ci

- name: Build Storybook
run: npm run build:storybook

- uses: actions/upload-pages-artifact@v3
name: Upload Storybook artifact
with:
path: docs
name: storybook-artifact-${{ github.run_id }}

# ---------------------
# 2. Deploy Next.js App
# ---------------------
# Configure GitHub Pages for Next.js
- uses: actions/configure-pages@v5
name: Configure GitHub Pages

- name: Restore cache
# Restore Next.js cache
- name: Restore Next.js 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', '**/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', '**/yarn.lock') }}-
- run: npm ci
name: Install dependencies

- run: npm run build
name: Build with Next.js
- name: Build Next.js app
run: npm run build

- uses: actions/upload-pages-artifact@v3
name: Upload artifact
name: Upload Next.js artifact
with:
path: ./out
name: nextjs-artifact-${{ github.run_id }}

deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: nextjs
steps:
# ---------------------
# 3. Deploy to GitHub Pages
# ---------------------
- uses: actions/deploy-pages@v4
id: deployment
name: Deploy to GitHub Pages
with:
# Deploy the Next.js artifact to the root
artifact-name: nextjs-artifact-${{ github.run_id }}
target-folder: /

- uses: actions/deploy-pages@v4
id: deployment-storybook
name: Deploy Storybook to /docs
with:
# Deploy the Storybook artifact to /docs
artifact-name: storybook-artifact-${{ github.run_id }}
target-folder: /docs

environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

0 comments on commit b67267a

Please sign in to comment.