2023-01-04 03:24:01 +08:00
|
|
|
name: Deploy PR to Spaces
|
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_run:
|
|
|
|
workflows: [Build PR Artifacts]
|
|
|
|
types:
|
|
|
|
- completed
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
deploy-current-pr:
|
2023-08-11 22:54:56 +08:00
|
|
|
outputs:
|
|
|
|
pr_number: ${{ steps.set-outputs.outputs.pr_number }}
|
|
|
|
space_url: ${{ steps.upload-demo.outputs.SPACE_URL }}
|
|
|
|
sha: ${{ steps.set-outputs.outputs.gh_sha }}
|
|
|
|
gradio_version: ${{ steps.set-outputs.outputs.gradio_version }}
|
2023-01-04 03:24:01 +08:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
if: >
|
|
|
|
github.event.workflow_run.event == 'pull_request' &&
|
|
|
|
github.event.workflow_run.conclusion == 'success'
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Install Python
|
2023-06-22 02:15:52 +08:00
|
|
|
uses: actions/setup-python@v4
|
2023-01-04 03:24:01 +08:00
|
|
|
with:
|
|
|
|
python-version: '3.9'
|
|
|
|
- name: Install pip
|
|
|
|
run: python -m pip install build requests
|
|
|
|
- name: Download metadata
|
|
|
|
run: python scripts/download_artifacts.py ${{github.event.workflow_run.id }} metadata.json ${{ secrets.COMMENT_TOKEN }} --owner ${{ github.repository_owner }}
|
|
|
|
- run: unzip metadata.json.zip
|
2023-08-11 22:54:56 +08:00
|
|
|
- name: set outputs
|
|
|
|
id: set-outputs
|
2023-01-04 03:24:01 +08:00
|
|
|
run: |
|
2023-08-11 22:54:56 +08:00
|
|
|
echo "wheel_name=$(python -c 'import json; print(json.load(open("metadata.json"))["wheel"])')" >> $GITHUB_OUTPUT
|
|
|
|
echo "gh_sha=$(python -c 'import json; print(json.load(open("metadata.json"))["gh_sha"])')" >> $GITHUB_OUTPUT
|
|
|
|
echo "gradio_version=$(python -c 'import json; print(json.load(open("metadata.json"))["version"])')" >> $GITHUB_OUTPUT
|
|
|
|
echo "pr_number=$(python -c 'import json; print(json.load(open("metadata.json"))["pr_number"])')" >> $GITHUB_OUTPUT
|
2023-01-04 03:24:01 +08:00
|
|
|
- name: 'Download wheel'
|
2023-08-11 22:54:56 +08:00
|
|
|
run: python scripts/download_artifacts.py ${{ github.event.workflow_run.id }} ${{ steps.set-outputs.outputs.wheel_name }} ${{ secrets.COMMENT_TOKEN }} --owner ${{ github.repository_owner }}
|
|
|
|
- run: unzip ${{ steps.set-outputs.outputs.wheel_name }}.zip
|
2023-01-04 03:24:01 +08:00
|
|
|
- name: Upload wheel
|
|
|
|
run: |
|
|
|
|
export AWS_ACCESS_KEY_ID=${{ secrets.PR_DEPLOY_KEY }}
|
|
|
|
export AWS_SECRET_ACCESS_KEY=${{ secrets.PR_DEPLOY_SECRET }}
|
|
|
|
export AWS_DEFAULT_REGION=us-east-1
|
2023-08-11 22:54:56 +08:00
|
|
|
aws s3 cp ${{ steps.set-outputs.outputs.wheel_name }} s3://gradio-builds/${{ steps.set-outputs.outputs.gh_sha }}/
|
2023-01-04 03:24:01 +08:00
|
|
|
- name: Install Hub Client Library
|
|
|
|
run: pip install huggingface-hub
|
|
|
|
- name: 'Download all_demos'
|
|
|
|
run: python scripts/download_artifacts.py ${{ github.event.workflow_run.id }} all_demos ${{ secrets.COMMENT_TOKEN }} --owner ${{ github.repository_owner }}
|
|
|
|
- run: unzip all_demos.zip -d all_demos
|
|
|
|
- run: cp -R all_demos/* demo/all_demos
|
|
|
|
- name: Upload demo to spaces
|
2023-08-11 22:54:56 +08:00
|
|
|
id: upload-demo
|
2023-01-04 03:24:01 +08:00
|
|
|
run: |
|
|
|
|
python scripts/upload_demo_to_space.py all_demos \
|
2023-08-11 22:54:56 +08:00
|
|
|
gradio-pr-deploys/pr-${{ steps.set-outputs.outputs.pr_number }}-all-demos \
|
2023-01-04 03:24:01 +08:00
|
|
|
${{ secrets.SPACES_DEPLOY_TOKEN }} \
|
2023-08-11 22:54:56 +08:00
|
|
|
--gradio-version ${{ steps.set-outputs.outputs.gradio_version }} > url.txt
|
|
|
|
echo "SPACE_URL=$(cat url.txt)" >> $GITHUB_OUTPUT
|
|
|
|
comment-spaces-success:
|
|
|
|
uses: "./.github/workflows/comment-queue.yml"
|
|
|
|
needs: [deploy-current-pr]
|
|
|
|
if: >
|
|
|
|
github.event.workflow_run.event == 'pull_request' &&
|
|
|
|
github.event.workflow_run.conclusion == 'success' &&
|
|
|
|
needs.deploy-current-pr.result == 'success'
|
|
|
|
secrets:
|
|
|
|
gh_token: ${{ secrets.COMMENT_TOKEN }}
|
|
|
|
with:
|
|
|
|
pr_number: ${{ needs.deploy-current-pr.outputs.pr_number }}
|
|
|
|
message: spaces~success~${{ needs.deploy-current-pr.outputs.space_url }}
|
|
|
|
additional_text: |
|
|
|
|
**Install Gradio from this PR**
|
|
|
|
```bash
|
|
|
|
pip install https://gradio-builds.s3.amazonaws.com/${{ needs.deploy-current-pr.outputs.sha }}/gradio-${{ needs.deploy-current-pr.outputs.gradio_version }}-py3-none-any.whl
|
|
|
|
```
|
2023-07-12 18:28:24 +08:00
|
|
|
|
2023-08-11 22:54:56 +08:00
|
|
|
**Install Gradio Python Client from this PR**
|
|
|
|
```bash
|
|
|
|
pip install "gradio-client @ git+https://github.com/gradio-app/gradio@${{ needs.deploy-current-pr.outputs.sha }}#subdirectory=client/python"
|
|
|
|
```
|
|
|
|
comment-spaces-failure:
|
|
|
|
uses: "./.github/workflows/comment-queue.yml"
|
|
|
|
needs: [deploy-current-pr]
|
|
|
|
if: always() && needs.deploy-current-pr.result == 'failure'
|
|
|
|
secrets:
|
|
|
|
gh_token: ${{ secrets.COMMENT_TOKEN }}
|
|
|
|
with:
|
|
|
|
pr_number: ${{ needs.deploy-current-pr.outputs.pr_number }}
|
2023-08-12 01:09:34 +08:00
|
|
|
message: spaces~failure~https://github.com/gradio-app/gradio/actions/runs/${{github.run_id}}/
|