-
Notifications
You must be signed in to change notification settings - Fork 2.3k
124 lines (115 loc) 路 4.95 KB
/
deploy-website.yml
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
name: "deploy / website"
on:
workflow_run:
workflows: ["trigger"]
types:
- requested
permissions:
statuses: write
concurrency:
group: "${{ github.event.workflow_run.head_repository.full_name }}-${{ github.event.workflow_run.head_branch }}-${{ github.workflow_ref }}"
cancel-in-progress: true
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 }}
found_pr: ${{ steps.changes.outputs.found_pr }}
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:
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 }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.changes.outputs.merge_sha }}
repository: ${{ needs.changes.outputs.mergeable == 'true' && github.repository || needs.changes.outputs.source_repo }}
- name: install dependencies
uses: "gradio-app/gradio/.github/actions/install-all-deps@main"
with:
always_install_pnpm: true
skip_build: true
- 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
- name: Install Vercel CLI
run: pnpm install --global vercel@latest
# preview
- name: Pull Vercel Environment Information
shell: bash
if: needs.changes.outputs.found_pr == 'true'
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
- name: Build Project Artifacts
if: needs.changes.outputs.found_pr == 'true'
shell: bash
run: vercel build --token=${{ secrets.VERCEL_TOKEN }}
- name: Deploy Project Artifacts to Vercel
if: needs.changes.outputs.found_pr == 'true'
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: 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_TOKEN }}
- name: Build Project Artifacts
if: needs.changes.outputs.source_repo == 'gradio-app/gradio' && needs.changes.outputs.source_branch == 'main'
shell: bash
run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
- 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_TOKEN }})" >> $GITHUB_ENV
comment-deploy-success:
uses: "./.github/workflows/comment-queue.yml"
needs: [deploy-website, changes]
if: needs.deploy-website.result == 'success' && needs.changes.outputs.found_pr == 'true'
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.found_pr == 'true'
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}}/