Skip to content

Deploy Theme

Deploy Theme #406

Workflow file for this run

name: Deploy Theme
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID_THEME }}
on:
workflow_dispatch:
inputs:
environment:
type: choice
default: next
description: Deploy to environment
options:
- production
- next
push:
branches:
- next
paths:
- 'apps/theme/**'
jobs:
Deploy-Production:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use node 20 and yarn cache
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'yarn'
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Build
run: yarn build
- name: Install Vercel CLI
run: yarn add vercel@latest
- name: Set default environment value if push event is triggered
id: defaultenvironment
run: |
ENVIRONMENT=${{ github.event.inputs.environment }}
echo "value=${ENVIRONMENT:-"next"}" >> "$GITHUB_OUTPUT"
- name: Pull Vercel Environment Information
run: vercel pull --yes --environment=${{(steps.defaultenvironment.outputs.value == 'next' && 'preview') || 'production'}} --token=${{ secrets.VERCEL_TOKEN }}
- name: Build Project Artifacts
run: vercel build ${{(steps.defaultenvironment.outputs.value == 'production' && '--prod') || ''}} --token=${{ secrets.VERCEL_TOKEN }}
- id: deploy
name: Deploy Project Artifacts to Vercel
run: echo "url=$(vercel deploy --prebuilt ${{(steps.defaultenvironment.outputs.value == 'production' && '--prod') || ''}} --token=${{ secrets.VERCEL_TOKEN }})" >> $GITHUB_OUTPUT
- name: Set Vercel alias
run: vercel alias --token=${{ secrets.VERCEL_TOKEN }} --scope=${{ secrets.VERCEL_TEAM }} set ${{ steps.deploy.outputs.url }} next.theme.designsystemet.no
if: steps.defaultenvironment.outputs.value == 'next'