gradio

Форк
0
/
deploy-website.yml 
123 строки · 5.0 Кб
1
name: "deploy / website"
2

3
on:
4
  workflow_run:
5
    workflows: ["trigger"]
6
    types: 
7
      - requested
8

9
permissions:
10
  statuses: write
11

12
concurrency:
13
  group: "${{ github.event.workflow_run.head_repository.full_name }}-${{ github.event.workflow_run.head_branch }}-${{ github.workflow_ref }}"
14
  cancel-in-progress: true
15
  
16

17
env:
18
  VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
19
  VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
20

21
jobs:
22
  changes:
23
    name: "changes"
24
    runs-on: ubuntu-latest
25
    outputs:
26
      should_run: ${{ steps.changes.outputs.should_run }}
27
      sha: ${{ steps.changes.outputs.sha }}
28
      merge_sha: ${{ steps.changes.outputs.merge_sha }}
29
      pr_number: ${{ steps.changes.outputs.pr_number }}
30
      source_branch: ${{ steps.changes.outputs.source_branch }}
31
      source_repo: ${{ steps.changes.outputs.source_repo }}
32
      found_pr: ${{ steps.changes.outputs.found_pr }}
33
      mergeable: ${{ steps.changes.outputs.mergeable }}
34
    steps:
35
      - uses: actions/checkout@v4
36
      - uses: "gradio-app/gradio/.github/actions/changes@main"
37
        id: changes
38
        with:
39
          type: "website"
40
          token: ${{ secrets.GITHUB_TOKEN }}
41
          commit_status: false
42
  comment-deploy-start:
43
    needs: changes
44
    uses: "./.github/workflows/comment-queue.yml"
45
    secrets:
46
      gh_token: ${{ secrets.COMMENT_TOKEN }}
47
    with:
48
      pr_number: ${{ needs.changes.outputs.pr_number }}
49
      message: website~pending~null
50
  deploy-website:
51
    name: "deploy-website"
52
    runs-on: ubuntu-latest
53
    needs: changes
54
    if: needs.changes.outputs.should_run == 'true'
55
    outputs:
56
      vercel_url: ${{ steps.output_url.outputs.vercel_url }}
57
    steps:
58
      - uses: actions/checkout@v4
59
        with:
60
          ref: ${{ needs.changes.outputs.merge_sha }}
61
          repository: ${{ needs.changes.outputs.mergeable == 'true' &&  github.repository || needs.changes.outputs.source_repo }}
62
      - name: install dependencies
63
        uses: "gradio-app/gradio/.github/actions/install-all-deps@main"
64
        with:
65
          always_install_pnpm: true
66
          skip_build: true
67
      - name: deploy json to aws
68
        if: needs.changes.outputs.source_branch == 'changeset-release/main' && needs.changes.outputs.source_repo == 'gradio-app/gradio'
69
        run: |
70
          export AWS_ACCESS_KEY_ID=${{ secrets.AWSACCESSKEYID }}
71
          export AWS_SECRET_ACCESS_KEY=${{ secrets.AWSSECRETKEY }}
72
          export AWS_DEFAULT_REGION=us-west-2
73
          version=$(jq -r .version js/_website/src/lib/json/version.json)
74
          aws s3 cp ./js/_website/src/lib/json/ s3://gradio-docs-json/$version/ --recursive
75
      - name: Install Vercel CLI
76
        run: pnpm install --global vercel@latest
77
      # preview
78
      - name: Pull Vercel Environment Information
79
        shell: bash
80
        if: needs.changes.outputs.found_pr == 'true'
81
        run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
82
      - name: Build Project Artifacts
83
        if: needs.changes.outputs.found_pr == 'true'
84
        shell: bash
85
        run: vercel build --token=${{ secrets.VERCEL_TOKEN }}
86
      - name: Deploy Project Artifacts to Vercel
87
        if: needs.changes.outputs.found_pr == 'true'
88
        id: output_url
89
        shell: bash
90
        run: echo "vercel_url=$(vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }})" >> $GITHUB_OUTPUT
91
      # production
92
      - name: Pull Vercel Environment Information
93
        if: needs.changes.outputs.source_repo == 'gradio-app/gradio' && needs.changes.outputs.source_branch == 'main'
94
        shell: bash
95
        run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
96
      - name: Build Project Artifacts
97
        if: needs.changes.outputs.source_repo == 'gradio-app/gradio' && needs.changes.outputs.source_branch == 'main'
98
        shell: bash
99
        run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
100
      - name: Deploy Project Artifacts to Vercel
101
        if: needs.changes.outputs.source_repo == 'gradio-app/gradio' && needs.changes.outputs.source_branch == 'main'
102
        shell: bash
103
        run: echo "VERCEL_URL=$(vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }})" >> $GITHUB_ENV
104
     
105

106
  comment-deploy-success:
107
    uses: "./.github/workflows/comment-queue.yml"
108
    needs: [deploy-website, changes]
109
    if: needs.deploy-website.result == 'success' && needs.changes.outputs.found_pr == 'true'
110
    secrets:
111
      gh_token: ${{ secrets.COMMENT_TOKEN }}
112
    with:
113
      pr_number: ${{ needs.changes.outputs.pr_number }}
114
      message: website~success~${{needs.deploy-website.outputs.vercel_url}}
115
  comment-deploy-failure:
116
    uses: "./.github/workflows/comment-queue.yml"
117
    needs: [deploy-website, changes]
118
    if: always() && needs.deploy-website.result == 'failure' && needs.changes.outputs.found_pr == 'true'
119
    secrets:
120
      gh_token: ${{ secrets.COMMENT_TOKEN }}
121
    with:
122
      pr_number: ${{ needs.changes.outputs.pr_number }}
123
      message: website~failure~https://github.com/gradio-app/gradio/actions/runs/${{github.run_id}}/
124
    
125

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.