graycoreio/daffodil

View on GitHub
.github/workflows/deploy.yml

Summary

Maintainability
Test Coverage
on:
  workflow_call: 
    inputs: 
      artifact:
        required: true
        description: 'The name of the artifact to download'
        type: string
      artifact-zip-name:
          required: false
          description: 'The name of the zip file in the artifact (omit if you do not store a zip INSIDE your artifact).'
          type: string
    secrets:
      VERCEL_TOKEN:
        required: true
      VERCEL_ORG:
        required: true
      VERCEL_NEXT_PROJECT_ID:
        required: true
      VERCEL_PROJECT_ID:
        required: true
jobs:
  next:
    name: 'Next'
    runs-on: ubuntu-latest
    environment: 
      name: next
      url: ${{ steps.vercel-deploy.outputs.url }}
    if: github.ref == 'refs/heads/develop'
    steps: 
      - uses: actions/download-artifact@v3
        with:
          name: ${{ inputs.artifact }}
      
      - run: unzip -q ${{ inputs.artifact-zip-name }} -d . && rm ${{ inputs.artifact-zip-name }}
        name: Unzip internal artifact zip
        if: inputs.artifact-zip-name

      - uses: graycoreio/github-actions/angular-universal-vercel@main
        id: vercel-deploy
        with:
          prod: true
          vercel_token: ${{ secrets.VERCEL_TOKEN }}
          vercel_org: ${{ secrets.VERCEL_ORG }}
          vercel_project_id: ${{ secrets.VERCEL_NEXT_PROJECT_ID }}
          ng_version: '17'
    
  production:
    name: 'Production'
    runs-on: ubuntu-latest
    if: startsWith(github.ref, 'refs/tags/v') 
    environment: 
      name: production
      url: ${{ steps.vercel-deploy.outputs.url }}
    steps: 
      - uses: actions/download-artifact@v3
        with:
          name: ${{ inputs.artifact }}
      
      - run: unzip -q ${{ inputs.artifact-zip-name }} -d . && rm ${{ inputs.artifact-zip-name }}
        name: Unzip internal artifact zip
        if: inputs.artifact-zip-name

      - uses: graycoreio/github-actions/angular-universal-vercel@main
        id: vercel-deploy
        with:
          prod: true
          vercel_token: ${{ secrets.VERCEL_TOKEN }}
          vercel_org: ${{ secrets.VERCEL_ORG }}
          vercel_project_id: ${{ secrets.VERCEL_PROJECT_ID }}
          ng_version: '17'