Skip to content

Deploy to Pages

Deploy to Pages #81

Workflow file for this run

name: Deploy to Pages
on:
workflow_dispatch:
# workflow_run:
# workflows: ["Test"]
# types:
# - completed
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
if: ${{ (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main') || (github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'main') }}
steps:
- name: Checkout πŸ›ŽοΈ
uses: actions/checkout@v4
- name: Cache πŸ’Ύ # https://nextjs.org/docs/messages/no-cache#github-actions
uses: actions/cache@v4
with:
path: |
~/.npm
${{ github.workspace }}/.next/cache
# Generate a new cache whenever packages or source files change.
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx', '**.json') }}
# If source files changed but packages didn't, rebuild from a prior cache.
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
- name: Node 🧰
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: 'npm'
- name: Install πŸ“¦
run: npm ci
- name: Build πŸ”§
run: |
npm run build -w ./packages/website --if-present
env:
SITE_URL: https://commercelayer.github.io/demo-store-core
NEXT_PUBLIC_BASE_PATH: /demo-store-core
NEXT_PUBLIC_CL_CLIENT_ID: ${{ secrets.NEXT_PUBLIC_CL_CLIENT_ID }}
NEXT_PUBLIC_JSON_DATA_FOLDER: data/json/
NEXT_PUBLIC_LOCALES_DATA_FOLDER: data/locales/
NEXT_PUBLIC_DEFAULT_LANGUAGE: en
NEXT_PUBLIC_DATA_FETCHING: ssg
- name: Setup Pages πŸ“„
uses: actions/configure-pages@v5
- name: Upload artifact πŸš€
uses: actions/upload-pages-artifact@v3
with:
path: ./packages/website/out/
deploy:
needs: [build]
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages πŸš€
id: deployment
uses: actions/deploy-pages@v4