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:
|
|
|
|
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
|
|
|
|
- name: Pipe metadata to env
|
|
|
|
run: |
|
|
|
|
echo "wheel_name=$(python -c 'import json; print(json.load(open("metadata.json"))["wheel"])')" >> $GITHUB_ENV
|
|
|
|
echo "gh_sha=$(python -c 'import json; print(json.load(open("metadata.json"))["gh_sha"])')" >> $GITHUB_ENV
|
|
|
|
echo "gradio_version=$(python -c 'import json; print(json.load(open("metadata.json"))["version"])')" >> $GITHUB_ENV
|
|
|
|
echo "pr_number=$(python -c 'import json; print(json.load(open("metadata.json"))["pr_number"])')" >> $GITHUB_ENV
|
|
|
|
- name: 'Download wheel'
|
|
|
|
run: python scripts/download_artifacts.py ${{ github.event.workflow_run.id }} ${{ env.wheel_name }} ${{ secrets.COMMENT_TOKEN }} --owner ${{ github.repository_owner }}
|
|
|
|
- run: unzip ${{ env.wheel_name }}.zip
|
|
|
|
- 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
|
|
|
|
aws s3 cp ${{ env.wheel_name }} s3://gradio-builds/${{ env.gh_sha }}/
|
|
|
|
- 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
|
|
|
|
run: |
|
|
|
|
python scripts/upload_demo_to_space.py all_demos \
|
|
|
|
gradio-pr-deploys/pr-${{ env.pr_number }}-all-demos \
|
|
|
|
${{ secrets.SPACES_DEPLOY_TOKEN }} \
|
|
|
|
--gradio-version ${{ env.gradio_version }} > url.txt
|
|
|
|
echo "SPACE_URL=$(cat url.txt)" >> $GITHUB_ENV
|
|
|
|
- name: Comment On Release PR
|
|
|
|
uses: thollander/actions-comment-pull-request@v1
|
|
|
|
with:
|
|
|
|
message: |
|
|
|
|
All the demos for this PR have been deployed at ${{ env.SPACE_URL }}
|
|
|
|
comment_includes: All the demos for this PR have been deployed at
|
|
|
|
GITHUB_TOKEN: ${{ secrets.COMMENT_TOKEN }}
|
|
|
|
pr_number: ${{ env.pr_number }}
|