2024-08-06 02:11:24 +08:00
|
|
|
name: "storybook-deploy"
|
2024-02-01 08:46:55 +08:00
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_run:
|
2024-08-05 22:27:26 +08:00
|
|
|
workflows: ["storybook-build"]
|
|
|
|
types:
|
2024-08-06 02:11:24 +08:00
|
|
|
- completed
|
2024-02-01 08:46:55 +08:00
|
|
|
|
|
|
|
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 }}"
|
2024-02-01 08:46:55 +08:00
|
|
|
cancel-in-progress: true
|
|
|
|
|
2024-08-08 01:27:01 +08:00
|
|
|
permissions: {}
|
|
|
|
|
2024-02-01 08:46:55 +08:00
|
|
|
jobs:
|
|
|
|
changes:
|
|
|
|
name: "changes"
|
|
|
|
runs-on: ubuntu-latest
|
2024-08-07 17:39:55 +08:00
|
|
|
if: github.event.workflow_run.conclusion == 'success'
|
2024-08-05 22:27:26 +08:00
|
|
|
permissions:
|
|
|
|
actions: read
|
2024-02-01 08:46:55 +08:00
|
|
|
outputs:
|
2024-08-05 22:27:26 +08:00
|
|
|
should_run: ${{ steps.json.outputs.should_run }}
|
|
|
|
sha: ${{ steps.json.outputs.sha }}
|
|
|
|
pr_number: ${{ steps.json.outputs.pr_number }}
|
|
|
|
source_branch: ${{ steps.json.outputs.source_branch }}
|
|
|
|
source_repo: ${{ steps.json.outputs.source_repo }}
|
|
|
|
labels: ${{ steps.json.outputs.labels }}
|
|
|
|
run_id: ${{ steps.json.outputs.run_id }}
|
2024-02-01 08:46:55 +08:00
|
|
|
steps:
|
2024-08-05 22:27:26 +08:00
|
|
|
- name: Download artifact
|
|
|
|
uses: actions/download-artifact@v4
|
2024-02-01 08:46:55 +08:00
|
|
|
with:
|
2024-08-06 02:01:52 +08:00
|
|
|
name: changes
|
2024-08-05 22:27:26 +08:00
|
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
run-id: ${{ github.event.workflow_run.id }}
|
|
|
|
- uses: gradio-app/github/actions/json-to-output@main
|
|
|
|
id: json
|
|
|
|
with:
|
|
|
|
path: output.json
|
2024-02-01 08:46:55 +08:00
|
|
|
comment-chromatic-start:
|
|
|
|
uses: "./.github/workflows/comment-queue.yml"
|
|
|
|
needs: changes
|
2024-08-08 02:16:53 +08:00
|
|
|
if: needs.changes.outputs.should_run == 'true' || contains(needs.changes.outputs.labels, 'no-visual-update')
|
2024-02-01 08:46:55 +08:00
|
|
|
secrets:
|
|
|
|
gh_token: ${{ secrets.COMMENT_TOKEN }}
|
|
|
|
with:
|
|
|
|
pr_number: ${{ needs.changes.outputs.pr_number }}
|
|
|
|
message: |
|
|
|
|
storybook~pending~null
|
2024-08-05 22:27:26 +08:00
|
|
|
update-status:
|
2024-08-08 01:27:01 +08:00
|
|
|
permissions:
|
|
|
|
actions: read
|
|
|
|
statuses: write
|
2024-08-05 22:27:26 +08:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: changes
|
2024-08-08 02:16:53 +08:00
|
|
|
if: needs.changes.outputs.should_run == 'false' || contains(needs.changes.outputs.labels, 'no-visual-update')
|
2024-08-05 22:27:26 +08:00
|
|
|
steps:
|
|
|
|
- name: update status
|
|
|
|
uses: gradio-app/github/actions/set-commit-status@main
|
|
|
|
with:
|
|
|
|
sha: ${{ needs.changes.outputs.sha }}
|
|
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
2024-08-07 00:39:49 +08:00
|
|
|
name: "UI Tests"
|
2024-08-05 22:27:26 +08:00
|
|
|
run_id: ${{ needs.changes.outputs.run_id }}
|
2024-08-06 02:11:24 +08:00
|
|
|
deploy:
|
2024-08-08 01:27:01 +08:00
|
|
|
permissions:
|
|
|
|
actions: read
|
|
|
|
contents: read
|
2024-08-05 22:27:26 +08:00
|
|
|
environment: storybook
|
2024-08-06 18:54:11 +08:00
|
|
|
name: "storybook-deploy"
|
2024-02-01 08:46:55 +08:00
|
|
|
needs: changes
|
2024-08-08 02:16:53 +08:00
|
|
|
if: needs.changes.outputs.should_run == 'true' && github.repository == 'gradio-app/gradio' && !contains(needs.changes.outputs.labels, 'no-visual-update')
|
2024-02-01 08:46:55 +08:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
outputs:
|
|
|
|
changes: ${{ steps.publish-chromatic.outputs.changeCount }}
|
|
|
|
errors: ${{ steps.publish-chromatic.outputs.errorCount }}
|
|
|
|
storybook_url: ${{ steps.publish-chromatic.outputs.storybookUrl }}
|
|
|
|
build_url: ${{ steps.publish-chromatic.outputs.buildUrl }}
|
|
|
|
steps:
|
2024-08-06 07:10:50 +08:00
|
|
|
- uses: actions/checkout@v4
|
|
|
|
with:
|
|
|
|
ref: ${{ needs.changes.outputs.source_branch }}
|
|
|
|
repository: ${{ needs.changes.outputs.source_repo }}
|
2024-08-06 07:29:24 +08:00
|
|
|
fetch-depth: 0
|
2024-08-05 22:27:26 +08:00
|
|
|
- name: dowload storybook artifacts
|
|
|
|
uses: actions/download-artifact@v4
|
2024-02-01 08:46:55 +08:00
|
|
|
with:
|
2024-08-05 22:27:26 +08:00
|
|
|
name: storybook-static
|
|
|
|
path: storybook-static
|
|
|
|
run-id: ${{ github.event.workflow_run.id }}
|
|
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
2024-08-06 02:01:52 +08:00
|
|
|
- name: list artifacts
|
|
|
|
run: ls -R .
|
2024-08-06 02:21:43 +08:00
|
|
|
- name: create dummy pkg.json
|
|
|
|
run: echo "{}" > package.json
|
2024-02-01 08:46:55 +08:00
|
|
|
- name: publish to chromatic
|
|
|
|
id: publish-chromatic
|
2024-08-13 06:09:07 +08:00
|
|
|
uses: chromaui/action@fdbe7756d4dbf493e2fbb822df73be7accd07e1c # @v11
|
2024-02-01 08:46:55 +08:00
|
|
|
with:
|
|
|
|
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
|
2024-08-05 22:27:26 +08:00
|
|
|
token: ${{ secrets.COMMIT_STATUS }}
|
2024-02-01 08:46:55 +08:00
|
|
|
onlyChanged: true
|
|
|
|
exitOnceUploaded: true
|
2024-08-05 22:27:26 +08:00
|
|
|
storybookBuildDir: storybook-static
|
|
|
|
|
2024-02-01 08:46:55 +08:00
|
|
|
comment-chromatic-end:
|
|
|
|
uses: "./.github/workflows/comment-queue.yml"
|
2024-08-06 02:11:24 +08:00
|
|
|
needs: [deploy, changes]
|
2024-02-01 08:46:55 +08:00
|
|
|
secrets:
|
|
|
|
gh_token: ${{ secrets.COMMENT_TOKEN }}
|
|
|
|
with:
|
2024-08-08 01:27:01 +08:00
|
|
|
pr_number: ${{ needs.changes.outputs.pr_number }}
|
2024-02-01 08:46:55 +08:00
|
|
|
message: |
|
2024-08-06 02:11:24 +08:00
|
|
|
storybook~success~${{ needs.deploy.outputs.storybook_url }}
|
2024-08-05 22:27:26 +08:00
|
|
|
|
2024-02-01 08:46:55 +08:00
|
|
|
comment-chromatic-fail:
|
|
|
|
uses: "./.github/workflows/comment-queue.yml"
|
2024-08-06 02:11:24 +08:00
|
|
|
needs: [deploy, changes]
|
2024-08-08 01:27:01 +08:00
|
|
|
if: always() && needs.deploy.result == 'failure'
|
2024-02-01 08:46:55 +08:00
|
|
|
secrets:
|
|
|
|
gh_token: ${{ secrets.COMMENT_TOKEN }}
|
|
|
|
with:
|
|
|
|
pr_number: ${{ needs.changes.outputs.pr_number }}
|
|
|
|
message: |
|
|
|
|
storybook~failure~https://github.com/gradio-app/gradio/actions/runs/${{github.run_id}}/
|