File size: 3,722 Bytes
a03b3ba |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
name: "deploy website"
on:
workflow_call:
inputs:
branch_name:
description: "The branch name"
type: string
pr_number:
description: "The PR number"
type: string
secrets:
vercel_token:
description: "Vercel API token"
gh_token:
description: "Github token"
required: true
vercel_org_id:
description: "Vercel organization ID"
required: true
vercel_project_id:
description: "Vercel project ID"
required: true
env:
VERCEL_ORG_ID: ${{ secrets.vercel_org_id }}
VERCEL_PROJECT_ID: ${{ secrets.vercel_project_id }}
jobs:
comment-deploy-start:
uses: "./.github/workflows/comment-queue.yml"
secrets:
gh_token: ${{ secrets.gh_token }}
with:
pr_number: ${{ inputs.pr_number }}
message: website~pending~null
deploy:
name: "Deploy website"
runs-on: ubuntu-latest
outputs:
vercel_url: ${{ steps.output_url.outputs.vercel_url }}
steps:
- uses: actions/checkout@v3
- name: install dependencies
uses: "./.github/actions/install-frontend-deps"
with:
always-install-pnpm: true
skip_build: true
- name: download artifacts
uses: actions/download-artifact@v4
with:
name: website-json-${{ inputs.pr_number }}
path: |
./js/_website/src/lib/json
- name: echo artifact path
shell: bash
run: ls ./js/_website/src/lib/json
- name: Install Vercel CLI
shell: bash
run: pnpm install --global vercel@latest
# preview
- name: Pull Vercel Environment Information
shell: bash
if: github.event_name == 'pull_request'
run: vercel pull --yes --environment=preview --token=${{ secrets.vercel_token }}
- name: Build Project Artifacts
if: github.event_name == 'pull_request'
shell: bash
run: vercel build --token=${{ secrets.vercel_token }}
- name: Deploy Project Artifacts to Vercel
if: github.event_name == 'pull_request'
id: output_url
shell: bash
run: echo "vercel_url=$(vercel deploy --prebuilt --token=${{ secrets.vercel_token }})" >> $GITHUB_OUTPUT
# production
- name: Pull Vercel Environment Information
if: github.event_name == 'push' && inputs.branch_name == 'main'
shell: bash
run: vercel pull --yes --environment=production --token=${{ secrets.vercel_token }}
- name: Build Project Artifacts
if: github.event_name == 'push' && inputs.branch_name == 'main'
shell: bash
run: vercel build --prod --token=${{ secrets.vercel_token }}
- name: Deploy Project Artifacts to Vercel
if: github.event_name == 'push' && inputs.branch_name == 'main'
shell: bash
run: echo "VERCEL_URL=$(vercel deploy --prebuilt --prod --token=${{ secrets.vercel_token }})" >> $GITHUB_ENV
- name: echo vercel url
shell: bash
run: echo $VERCEL_URL #add to comment
comment-deploy-success:
uses: "./.github/workflows/comment-queue.yml"
needs: deploy
if: needs.deploy.result == 'success'
secrets:
gh_token: ${{ secrets.gh_token }}
with:
pr_number: ${{ inputs.pr_number }}
message: website~success~${{needs.deploy.outputs.vercel_url}}
comment-deploy-failure:
uses: "./.github/workflows/comment-queue.yml"
needs: deploy
if: always() && needs.deploy.result == 'failure'
secrets:
gh_token: ${{ secrets.gh_token }}
with:
pr_number: ${{ inputs.pr_number }}
message: website~failure~https://github.com/gradio-app/gradio/actions/runs/${{github.run_id}}/ |