2024-02-01 08:46:55 +08:00
|
|
|
name: "deploy / website"
|
2023-08-11 22:54:56 +08:00
|
|
|
|
|
|
|
on:
|
2024-02-01 08:46:55 +08:00
|
|
|
workflow_run:
|
|
|
|
workflows: ["trigger"]
|
|
|
|
types:
|
|
|
|
- requested
|
|
|
|
|
|
|
|
permissions:
|
|
|
|
statuses: write
|
|
|
|
|
|
|
|
concurrency:
|
2024-02-01 18:24:15 +08:00
|
|
|
group: "${{ github.event.workflow_run.head_repository.full_name }}-${{ github.event.workflow_run.head_branch }}-${{ github.workflow_ref }}"
|
2024-02-01 08:46:55 +08:00
|
|
|
cancel-in-progress: true
|
|
|
|
|
2023-08-11 22:54:56 +08:00
|
|
|
|
|
|
|
env:
|
2024-02-01 08:46:55 +08:00
|
|
|
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
|
|
|
|
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
|
2023-08-11 22:54:56 +08:00
|
|
|
|
|
|
|
jobs:
|
2024-02-01 08:46:55 +08:00
|
|
|
changes:
|
|
|
|
name: "changes"
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
outputs:
|
|
|
|
should_run: ${{ steps.changes.outputs.should_run }}
|
|
|
|
sha: ${{ steps.changes.outputs.sha }}
|
|
|
|
merge_sha: ${{ steps.changes.outputs.merge_sha }}
|
|
|
|
pr_number: ${{ steps.changes.outputs.pr_number }}
|
|
|
|
source_branch: ${{ steps.changes.outputs.source_branch }}
|
|
|
|
source_repo: ${{ steps.changes.outputs.source_repo }}
|
|
|
|
found_pr: ${{ steps.changes.outputs.found_pr }}
|
2024-02-01 21:15:15 +08:00
|
|
|
mergeable: ${{ steps.changes.outputs.mergeable }}
|
2024-02-01 08:46:55 +08:00
|
|
|
steps:
|
2024-02-02 02:14:41 +08:00
|
|
|
- uses: actions/checkout@v4
|
2024-02-01 18:34:22 +08:00
|
|
|
- uses: "gradio-app/gradio/.github/actions/changes@main"
|
2024-02-01 08:46:55 +08:00
|
|
|
id: changes
|
|
|
|
with:
|
|
|
|
type: "website"
|
|
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
commit_status: false
|
2023-08-11 22:54:56 +08:00
|
|
|
comment-deploy-start:
|
2024-02-01 08:46:55 +08:00
|
|
|
needs: changes
|
2023-08-11 22:54:56 +08:00
|
|
|
uses: "./.github/workflows/comment-queue.yml"
|
|
|
|
secrets:
|
2024-02-01 08:46:55 +08:00
|
|
|
gh_token: ${{ secrets.COMMENT_TOKEN }}
|
2023-08-11 22:54:56 +08:00
|
|
|
with:
|
2024-02-01 08:46:55 +08:00
|
|
|
pr_number: ${{ needs.changes.outputs.pr_number }}
|
2023-08-11 22:54:56 +08:00
|
|
|
message: website~pending~null
|
2024-02-01 08:46:55 +08:00
|
|
|
deploy-website:
|
|
|
|
name: "deploy-website"
|
2023-08-11 22:54:56 +08:00
|
|
|
runs-on: ubuntu-latest
|
2024-02-01 08:46:55 +08:00
|
|
|
needs: changes
|
|
|
|
if: needs.changes.outputs.should_run == 'true'
|
2023-08-11 22:54:56 +08:00
|
|
|
outputs:
|
|
|
|
vercel_url: ${{ steps.output_url.outputs.vercel_url }}
|
|
|
|
steps:
|
2024-02-02 02:14:41 +08:00
|
|
|
- uses: actions/checkout@v4
|
2024-02-01 08:46:55 +08:00
|
|
|
with:
|
|
|
|
ref: ${{ needs.changes.outputs.merge_sha }}
|
2024-02-01 21:15:15 +08:00
|
|
|
repository: ${{ needs.changes.outputs.mergeable == 'true' && github.repository || needs.changes.outputs.source_repo }}
|
2023-08-11 22:54:56 +08:00
|
|
|
- name: install dependencies
|
2024-02-01 18:34:22 +08:00
|
|
|
uses: "gradio-app/gradio/.github/actions/install-all-deps@main"
|
2023-08-11 22:54:56 +08:00
|
|
|
with:
|
2024-02-01 08:46:55 +08:00
|
|
|
always_install_pnpm: true
|
2023-08-11 22:54:56 +08:00
|
|
|
skip_build: true
|
2024-06-15 18:19:54 +08:00
|
|
|
- name: build client
|
|
|
|
run: pnpm --filter @gradio/client build
|
2024-02-01 08:46:55 +08:00
|
|
|
- name: deploy json to aws
|
|
|
|
if: needs.changes.outputs.source_branch == 'changeset-release/main' && needs.changes.outputs.source_repo == 'gradio-app/gradio'
|
|
|
|
run: |
|
|
|
|
export AWS_ACCESS_KEY_ID=${{ secrets.AWSACCESSKEYID }}
|
|
|
|
export AWS_SECRET_ACCESS_KEY=${{ secrets.AWSSECRETKEY }}
|
|
|
|
export AWS_DEFAULT_REGION=us-west-2
|
|
|
|
version=$(jq -r .version js/_website/src/lib/json/version.json)
|
|
|
|
aws s3 cp ./js/_website/src/lib/json/ s3://gradio-docs-json/$version/ --recursive
|
2024-05-30 06:26:54 +08:00
|
|
|
aws s3 cp ./js/_website/src/lib/templates/ s3://gradio-docs-json/$version/templates/ --recursive
|
2023-08-11 22:54:56 +08:00
|
|
|
- name: Install Vercel CLI
|
|
|
|
run: pnpm install --global vercel@latest
|
|
|
|
# preview
|
|
|
|
- name: Pull Vercel Environment Information
|
|
|
|
shell: bash
|
2024-02-01 08:46:55 +08:00
|
|
|
if: needs.changes.outputs.found_pr == 'true'
|
|
|
|
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
|
2023-08-11 22:54:56 +08:00
|
|
|
- name: Build Project Artifacts
|
2024-02-01 08:46:55 +08:00
|
|
|
if: needs.changes.outputs.found_pr == 'true'
|
2023-08-11 22:54:56 +08:00
|
|
|
shell: bash
|
2024-02-01 08:46:55 +08:00
|
|
|
run: vercel build --token=${{ secrets.VERCEL_TOKEN }}
|
2023-08-11 22:54:56 +08:00
|
|
|
- name: Deploy Project Artifacts to Vercel
|
2024-02-01 08:46:55 +08:00
|
|
|
if: needs.changes.outputs.found_pr == 'true'
|
2023-08-11 22:54:56 +08:00
|
|
|
id: output_url
|
|
|
|
shell: bash
|
2024-02-01 08:46:55 +08:00
|
|
|
run: echo "vercel_url=$(vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }})" >> $GITHUB_OUTPUT
|
2023-08-11 22:54:56 +08:00
|
|
|
# production
|
|
|
|
- name: Pull Vercel Environment Information
|
2024-02-01 08:46:55 +08:00
|
|
|
if: needs.changes.outputs.source_repo == 'gradio-app/gradio' && needs.changes.outputs.source_branch == 'main'
|
2023-08-11 22:54:56 +08:00
|
|
|
shell: bash
|
2024-02-01 08:46:55 +08:00
|
|
|
run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
|
2023-08-11 22:54:56 +08:00
|
|
|
- name: Build Project Artifacts
|
2024-02-01 08:46:55 +08:00
|
|
|
if: needs.changes.outputs.source_repo == 'gradio-app/gradio' && needs.changes.outputs.source_branch == 'main'
|
2023-08-11 22:54:56 +08:00
|
|
|
shell: bash
|
2024-02-01 08:46:55 +08:00
|
|
|
run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
|
2023-08-11 22:54:56 +08:00
|
|
|
- name: Deploy Project Artifacts to Vercel
|
2024-02-01 08:46:55 +08:00
|
|
|
if: needs.changes.outputs.source_repo == 'gradio-app/gradio' && needs.changes.outputs.source_branch == 'main'
|
2023-08-11 22:54:56 +08:00
|
|
|
shell: bash
|
2024-02-01 08:46:55 +08:00
|
|
|
run: echo "VERCEL_URL=$(vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }})" >> $GITHUB_ENV
|
|
|
|
|
|
|
|
|
2023-08-11 22:54:56 +08:00
|
|
|
comment-deploy-success:
|
|
|
|
uses: "./.github/workflows/comment-queue.yml"
|
2024-02-01 08:46:55 +08:00
|
|
|
needs: [deploy-website, changes]
|
|
|
|
if: needs.deploy-website.result == 'success' && needs.changes.outputs.found_pr == 'true'
|
2023-08-11 22:54:56 +08:00
|
|
|
secrets:
|
2024-02-01 08:46:55 +08:00
|
|
|
gh_token: ${{ secrets.COMMENT_TOKEN }}
|
2023-08-11 22:54:56 +08:00
|
|
|
with:
|
2024-02-01 08:46:55 +08:00
|
|
|
pr_number: ${{ needs.changes.outputs.pr_number }}
|
|
|
|
message: website~success~${{needs.deploy-website.outputs.vercel_url}}
|
2023-08-11 22:54:56 +08:00
|
|
|
comment-deploy-failure:
|
|
|
|
uses: "./.github/workflows/comment-queue.yml"
|
2024-02-01 08:46:55 +08:00
|
|
|
needs: [deploy-website, changes]
|
|
|
|
if: always() && needs.deploy-website.result == 'failure' && needs.changes.outputs.found_pr == 'true'
|
2023-08-11 22:54:56 +08:00
|
|
|
secrets:
|
2024-02-01 08:46:55 +08:00
|
|
|
gh_token: ${{ secrets.COMMENT_TOKEN }}
|
2023-08-11 22:54:56 +08:00
|
|
|
with:
|
2024-02-01 08:46:55 +08:00
|
|
|
pr_number: ${{ needs.changes.outputs.pr_number }}
|
|
|
|
message: website~failure~https://github.com/gradio-app/gradio/actions/runs/${{github.run_id}}/
|
|
|
|
|