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"]
|
2024-08-05 22:27:26 +08:00
|
|
|
types:
|
2024-02-01 08:46:55 +08:00
|
|
|
- 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
|
|
|
|
2024-07-31 16:01:57 +08:00
|
|
|
# these variables are not secret and are used to identify the Vercel project
|
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 }}
|
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:
|
2024-08-05 22:27:26 +08:00
|
|
|
environment: deploy_website
|
2024-02-01 08:46:55 +08:00
|
|
|
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 }}
|
2024-08-05 22:27:26 +08:00
|
|
|
env:
|
|
|
|
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
|
|
|
|
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
|
2023-08-11 22:54:56 +08:00
|
|
|
steps:
|
2024-08-05 22:27:26 +08:00
|
|
|
- uses: actions/download-artifact@v4
|
2024-02-01 08:46:55 +08:00
|
|
|
with:
|
2024-08-05 22:27:26 +08:00
|
|
|
name: website-json
|
|
|
|
path: js/_website/lib/json
|
|
|
|
- uses: actions/download-artifact@v4
|
2023-08-11 22:54:56 +08:00
|
|
|
with:
|
2024-08-05 22:27:26 +08:00
|
|
|
name: website-templates
|
|
|
|
path: js/_website/lib/templates
|
|
|
|
|
2024-02-01 08:46:55 +08:00
|
|
|
- name: deploy json to aws
|
2024-07-18 19:25:50 +08:00
|
|
|
if: startsWith(needs.changes.outputs.source_branch, 'changeset-release/') && needs.changes.outputs.source_repo == 'gradio-app/gradio'
|
2024-02-01 08:46:55 +08:00
|
|
|
run: |
|
2024-08-05 22:27:26 +08:00
|
|
|
export AWS_ACCESS_KEY_ID=${{ secrets.DOCS_JSON_AWS_S3_ACCESS_KEY }}
|
|
|
|
export AWS_SECRET_ACCESS_KEY=${{ secrets.DOCS_JSON_AWS_S3_SECRET_ACCESS_KEY }}
|
2024-02-01 08:46:55 +08:00
|
|
|
export AWS_DEFAULT_REGION=us-west-2
|
2024-08-05 22:27:26 +08:00
|
|
|
version=$(jq -r .version js/_website/lib/json/version.json)
|
|
|
|
aws s3 cp ./js/_website/lib/json/ s3://gradio-docs-json/$version/ --recursive
|
|
|
|
aws s3 cp ./js/_website/lib/templates/ s3://gradio-docs-json/$version/templates/ --recursive
|
|
|
|
|
|
|
|
- name: download website artifacts
|
|
|
|
uses: actions/download-artifact@v4
|
|
|
|
with:
|
|
|
|
name: website
|
|
|
|
path: js/_website/.vercel
|
|
|
|
|
2023-08-11 22:54:56 +08:00
|
|
|
# preview
|
|
|
|
- name: Pull Vercel Environment Information
|
|
|
|
shell: bash
|
2024-08-05 22:27:26 +08:00
|
|
|
if: needs.changes.outputs.pr_number != 'false'
|
|
|
|
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_DEPLOY_TOKEN }} --cwd js/_website
|
|
|
|
|
2023-08-11 22:54:56 +08:00
|
|
|
- name: Deploy Project Artifacts to Vercel
|
2024-08-05 22:27:26 +08:00
|
|
|
if: needs.changes.outputs.pr_number != 'true'
|
2023-08-11 22:54:56 +08:00
|
|
|
id: output_url
|
|
|
|
shell: bash
|
2024-08-05 22:27:26 +08:00
|
|
|
run: echo "vercel_url=$(vercel deploy --prebuilt --token=${{ secrets.VERCEL_DEPLOY_TOKEN }} --cwd js/_website)" >> $GITHUB_OUTPUT
|
|
|
|
|
|
|
|
# production
|
2023-08-11 22:54:56 +08:00
|
|
|
- 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-08-05 22:27:26 +08:00
|
|
|
run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_DEPLOY_TOKEN }} --cwd js/_website
|
|
|
|
|
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-08-05 22:27:26 +08:00
|
|
|
run: echo "VERCEL_URL=$(vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_DEPLOY_TOKEN }})" --cwd js/_website >> $GITHUB_ENV
|
2024-02-01 08:46:55 +08:00
|
|
|
|
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]
|
2024-08-05 22:27:26 +08:00
|
|
|
if: needs.deploy-website.result == 'success' && needs.changes.outputs.pr_number != 'false'
|
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]
|
2024-08-05 22:27:26 +08:00
|
|
|
if: always() && needs.deploy-website.result == 'failure' && needs.changes.outputs.pr_number != 'false'
|
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}}/
|