gradio/.github/workflows/website-deploy.yml

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

127 lines
4.9 KiB
YAML
Raw Normal View History

name: "deploy / website"
on:
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 }}"
cancel-in-progress: true
2024-07-31 16:01:57 +08:00
# these variables are not secret and are used to identify the Vercel project
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
jobs:
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 }}
mergeable: ${{ steps.changes.outputs.mergeable }}
steps:
- uses: actions/checkout@v4
- uses: "gradio-app/gradio/.github/actions/changes@main"
id: changes
with:
type: "website"
token: ${{ secrets.GITHUB_TOKEN }}
commit_status: false
comment-deploy-start:
needs: changes
uses: "./.github/workflows/comment-queue.yml"
secrets:
gh_token: ${{ secrets.COMMENT_TOKEN }}
with:
pr_number: ${{ needs.changes.outputs.pr_number }}
message: website~pending~null
deploy-website:
environment: deploy_website
name: "deploy-website"
runs-on: ubuntu-latest
needs: changes
if: needs.changes.outputs.should_run == 'true'
outputs:
vercel_url: ${{ steps.output_url.outputs.vercel_url }}
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
steps:
- uses: actions/download-artifact@v4
with:
name: website-json
path: js/_website/lib/json
- uses: actions/download-artifact@v4
with:
name: website-templates
path: js/_website/lib/templates
- name: deploy json to aws
if: startsWith(needs.changes.outputs.source_branch, 'changeset-release/') && needs.changes.outputs.source_repo == 'gradio-app/gradio'
run: |
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 }}
export AWS_DEFAULT_REGION=us-west-2
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
# preview
- name: Pull Vercel Environment Information
shell: bash
if: needs.changes.outputs.pr_number != 'false'
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_DEPLOY_TOKEN }} --cwd js/_website
- name: Deploy Project Artifacts to Vercel
if: needs.changes.outputs.pr_number != 'true'
id: output_url
shell: bash
run: echo "vercel_url=$(vercel deploy --prebuilt --token=${{ secrets.VERCEL_DEPLOY_TOKEN }} --cwd js/_website)" >> $GITHUB_OUTPUT
# production
- name: Pull Vercel Environment Information
if: needs.changes.outputs.source_repo == 'gradio-app/gradio' && needs.changes.outputs.source_branch == 'main'
shell: bash
run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_DEPLOY_TOKEN }} --cwd js/_website
- name: Deploy Project Artifacts to Vercel
if: needs.changes.outputs.source_repo == 'gradio-app/gradio' && needs.changes.outputs.source_branch == 'main'
shell: bash
run: echo "VERCEL_URL=$(vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_DEPLOY_TOKEN }})" --cwd js/_website >> $GITHUB_ENV
comment-deploy-success:
uses: "./.github/workflows/comment-queue.yml"
needs: [deploy-website, changes]
if: needs.deploy-website.result == 'success' && needs.changes.outputs.pr_number != 'false'
secrets:
gh_token: ${{ secrets.COMMENT_TOKEN }}
with:
pr_number: ${{ needs.changes.outputs.pr_number }}
message: website~success~${{needs.deploy-website.outputs.vercel_url}}
comment-deploy-failure:
uses: "./.github/workflows/comment-queue.yml"
needs: [deploy-website, changes]
if: always() && needs.deploy-website.result == 'failure' && needs.changes.outputs.pr_number != 'false'
secrets:
gh_token: ${{ secrets.COMMENT_TOKEN }}
with:
pr_number: ${{ needs.changes.outputs.pr_number }}
message: website~failure~https://github.com/gradio-app/gradio/actions/runs/${{github.run_id}}/