domjtalbot/nx-mesh

View on GitHub
.github/workflows/__deploy.yml

Summary

Maintainability
Test Coverage
name: 'Deploy'

on:
  workflow_call:
    inputs:
      affected:
        description: >
          Run for affected projects.
        required: false
        default: true
        type: boolean
      production:
        description: Deploy production?
        type: boolean
        required: false
        default: false
    secrets:
      VERCEL_ORG_ID:
        description: 'The Vercel ORG ID'
        required: true
      NX__NEXTJS__VERCEL_PROJECT_ID:
        description: 'The nextjs/trippin Vercel Project Id'
        required: true
      VERCEL_TOKEN:
        description: 'The Vercel API token'
        required: true

concurrency:
  group: deploy-${{ github.workflow }}-${{ github.ref }}

jobs:
  setup:
    name: Setup
    runs-on: ubuntu-latest
    outputs:
      isNxMeshAffected: ${{ contains(steps.setup.outputs.affectedLibs, 'nx-mesh') }}
      affectedApps: ${{ steps.setup.outputs.affectedApps }}
      suffix: ${{ steps.suffix.outputs.name }}
    steps:
      - name: Check out repository
        uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
        with:
          fetch-depth: 0

      - name: Setup Job
        id: setup
        uses: ./.github/actions/setup-job
        with:
          node_version: 'lts/*'

      - name: Environment suffix
        id: suffix
        shell: bash
        run: |
          name="-preview"

          if [ ${{ inputs.production }} = true ]; then
            name=""
          fi

          echo The env is $name
          echo "name=$name" >> $GITHUB_OUTPUT

  vercel-examples-sdk-nextjs:
    name: Vercel - examples-sdk-nextjs
    needs: [setup]
    if: ${{ (inputs.affected == true && contains(needs.setup.outputs.affectedApps, 'examples-sdk-nextjs')) || inputs.affected == false }}
    uses: ./.github/workflows/__deploy-vercel.yml
    with:
      name: examples-sdk-nextjs${{ needs.setup.outputs.suffix }}
      production: ${{ inputs.production }}
    secrets:
      VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
      VERCEL_PROJECT_ID: ${{ secrets.NX__NEXTJS__VERCEL_PROJECT_ID }}
      VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}