13
group: "${{ github.event.workflow_run.head_repository.full_name }}-${{ github.event.workflow_run.head_branch }}-${{ github.workflow_ref }}"
14
cancel-in-progress: true
19
runs-on: ubuntu-latest
21
should_run: ${{ steps.changes.outputs.should_run }}
22
sha: ${{ steps.changes.outputs.sha }}
23
pr_number: ${{ steps.changes.outputs.pr_number }}
24
source_branch: ${{ steps.changes.outputs.source_branch }}
25
source_repo: ${{ steps.changes.outputs.source_repo }}
26
merge_sha: ${{ steps.changes.outputs.merge_sha }}
27
mergeable: ${{ steps.changes.outputs.mergeable }}
28
found_pr: ${{ steps.changes.outputs.found_pr }}
30
- uses: actions/checkout@v4
31
- uses: "gradio-app/gradio/.github/actions/changes@main"
35
name: "deploy / spaces"
36
token: ${{ secrets.GITHUB_TOKEN }}
41
uses: "./.github/workflows/comment-queue.yml"
42
if: ${{ needs.changes.outputs.should_run == 'true' }}
44
gh_token: ${{ secrets.COMMENT_TOKEN }}
46
pr_number: ${{ needs.changes.outputs.pr_number }}
47
message: spaces~pending~null
50
space_url: ${{ steps.upload-demo.outputs.SPACE_URL }}
51
gradio_version: ${{ steps.get_gradio_version.outputs.gradio_version }}
53
if: ${{ needs.changes.outputs.should_run == 'true' }}
54
runs-on: ubuntu-latest
56
- uses: actions/checkout@v4
58
ref: ${{ needs.changes.outputs.merge_sha }}
59
repository: ${{ needs.changes.outputs.mergeable == 'true' && github.repository || needs.changes.outputs.source_repo }}
60
- name: Install Python
61
uses: actions/setup-python@v5
65
uses: pnpm/action-setup@v2
68
- uses: actions/setup-node@v4
72
cache-dependency-path: pnpm-lock.yaml
74
run: python -m pip install build requests
75
- name: Get Gradio Version
76
id: get_gradio_version
78
if ${{ github.event_name == 'pull_request' || github.event.workflow_run.event == 'pull_request' }}; then
79
echo "GRADIO_VERSION=$(python -c 'import requests;print(requests.get("https://pypi.org/pypi/gradio/json").json()["info"]["version"])')" >> $GITHUB_OUTPUT
80
python -c "import os;print(os.environ['GITHUB_REF'].split('/')[2])" > pr_number.txt
82
echo "GRADIO_VERSION=$(python -c 'import json; print(json.load(open("gradio/package.json"))["version"])')" >> $GITHUB_OUTPUT
84
- name: Build pr package
86
python -c 'import json; j = json.load(open("gradio/package.json")); j["version"] = "${{ steps.get_gradio_version.outputs.GRADIO_VERSION }}"; json.dump(j, open("gradio/package.json", "w"))'
87
pnpm i --frozen-lockfile --ignore-scripts
91
NODE_OPTIONS: --max_old_space_size=8192
95
python scripts/copy_demos.py https://gradio-builds.s3.amazonaws.com/${{ needs.changes.outputs.sha }}/gradio-${{ steps.get_gradio_version.outputs.GRADIO_VERSION }}-py3-none-any.whl \
96
"gradio-client @ git+https://github.com/gradio-app/gradio@${{ needs.changes.outputs.sha }}#subdirectory=client/python"
99
export AWS_ACCESS_KEY_ID=${{ secrets.PR_DEPLOY_KEY }}
100
export AWS_SECRET_ACCESS_KEY=${{ secrets.PR_DEPLOY_SECRET }}
101
export AWS_DEFAULT_REGION=us-east-1
102
aws s3 cp dist/gradio-${{ steps.get_gradio_version.outputs.GRADIO_VERSION }}-py3-none-any.whl s3://gradio-builds/${{ needs.changes.outputs.sha }}/
103
- name: Install Hub Client Library
104
run: pip install huggingface-hub
105
- name: Upload demo to spaces
106
if: github.event.workflow_run.event == 'pull_request'
109
python scripts/upload_demo_to_space.py all_demos \
110
gradio-pr-deploys/pr-${{ needs.changes.outputs.pr_number }}-all-demos \
111
${{ secrets.SPACES_DEPLOY_TOKEN }} \
112
--gradio-version ${{ steps.get_gradio_version.outputs.GRADIO_VERSION }} > url.txt
113
echo "SPACE_URL=$(cat url.txt)" >> $GITHUB_OUTPUT
114
- name: Upload Website Demos
115
if: github.event_name == 'workflow_dispatch'
116
id: upload-website-demos
118
python scripts/upload_website_demos.py --AUTH_TOKEN ${{ secrets.WEBSITE_SPACES_DEPLOY_TOKEN }} \
119
--WHEEL_URL https://gradio-builds.s3.amazonaws.com/${{ needs.changes.outputs.sha }}/ \
120
--CLIENT_URL "gradio-client @ git+https://github.com/gradio-app/gradio@${{ needs.changes.outputs.sha }}#subdirectory=client/python" \
121
--GRADIO_VERSION ${{ steps.get_gradio_version.outputs.GRADIO_VERSION }}
124
echo ${{github.event.workflow_run.event }}
125
echo ${{ github.event.workflow_run.conclusion }}
127
comment-spaces-success:
128
uses: "./.github/workflows/comment-queue.yml"
129
needs: [deploy-spaces, changes]
130
if: needs.deploy-spaces.result == 'success' && needs.changes.outputs.found_pr == 'true'
132
gh_token: ${{ secrets.COMMENT_TOKEN }}
134
pr_number: ${{ needs.changes.outputs.pr_number }}
135
message: spaces~success~${{ needs.deploy-spaces.outputs.space_url }}
137
**Install Gradio from this PR**
139
pip install https://gradio-builds.s3.amazonaws.com/${{ needs.changes.outputs.sha }}/gradio-${{ needs.deploy-spaces.outputs.gradio_version }}-py3-none-any.whl
142
**Install Gradio Python Client from this PR**
144
pip install "gradio-client @ git+https://github.com/gradio-app/gradio@${{ needs.changes.outputs.sha }}#subdirectory=client/python"
146
comment-spaces-failure:
147
uses: "./.github/workflows/comment-queue.yml"
148
needs: [deploy-spaces, changes]
149
if: always() && needs.deploy-spaces == 'failure' && needs.changes.outputs.found_pr == 'true'
151
gh_token: ${{ secrets.COMMENT_TOKEN }}
153
pr_number: ${{ needs.changes.outputs.pr_number }}
154
message: spaces~failure~https://github.com/gradio-app/gradio/actions/runs/${{github.run_id}}/