-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
action.yml
151 lines (148 loc) 路 4.83 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
name: "prepare"
description: "Prepare workflow"
inputs:
type:
description: "Type of workflow"
default: "one of: `gradio`, `python-client`, `js`, `js-client`, `functional`"
token:
description: "Github token"
required: true
name:
description: "Check name"
default: "false"
commit_status:
description: "Whether to create a commit status"
default: "true"
outputs:
should_run:
description: "Whether to run the workflow"
value: ${{ steps.should_run.outputs.should_run }}
pr_number:
description: "PR number"
value: ${{ steps.pr.outputs.pr_number }}
sha:
description: "SHA of the HEAD commit of the PR"
value: ${{ steps.pr.outputs.sha }}
source_repo:
description: "Source repo"
value: ${{ steps.pr.outputs.source_repo }}
source_branch:
description: "Source branch"
value: ${{ steps.pr.outputs.source_branch }}
merge_sha:
description: "SHA of the merged result preview branch"
value: ${{ steps.pr.outputs.merge_sha }}
mergeable:
description: "Whether the PR is mergeable"
value: ${{ steps.pr.outputs.mergeable }}
labels:
description: "Labels on the PR"
value: ${{ steps.pr.outputs.labels }}
found_pr:
description: "Whether a PR was found"
value: ${{ steps.pr.outputs.found_pr }}
runs:
using: "composite"
steps:
- name: "Get PR number"
id: pr
uses: "gradio-app/github/actions/find-pr@main"
with:
github_token: ${{ inputs.token }}
- uses: actions/checkout@v4
with:
repository: ${{ github.repository }}
ref: ${{ steps.pr.outputs.sha }}
fetch-depth: 0
token: ${{ inputs.token }}
- uses: dorny/paths-filter@v3
id: changes
with:
base: main
ref: ${{ steps.pr.outputs.sha == github.sha && 'main' || steps.pr.outputs.sha }}
filters: |
gradio:
- 'client/python/**'
- 'gradio/**'
- 'requirements.txt'
- '.github/**'
- 'scripts/**'
- 'test/**'
js:
- 'js/**'
- 'client/js/**'
- '.github/**'
- 'package.json'
- 'pnpm-lock.yaml'
- 'tsconfig.json'
- '.config/**'
functional:
- '.github/**'
- 'client/**'
- 'demo/**'
- 'gradio/**'
- 'js/**'
- 'scripts/**'
- 'globals.d.ts'
- 'package.json'
- 'pnpm-lock.yaml'
- 'pyproject.toml'
- 'requirements.txt'
- '.config/**'
visual:
- '.github/workflows/deploy-chromatic.yml'
- 'js!(/_website)/**'
- 'package.json'
website:
- 'js/_website/**'
- 'package.json'
- 'pnpm-lock.yaml'
- 'guides/**'
- 'README.md'
- 'CHANGELOG.md'
- 'gradio/**'
- 'client/**'
- 'demo/**'
- '.github/deplooy-website.yml'
- name: set env (gradio)
if: ${{ inputs.type == 'gradio' }}
shell: bash
run: echo "SHOULD_RUN=${{ steps.changes.outputs.gradio == 'true' }}" >> $GITHUB_ENV
- name: set env (js)
if: ${{ inputs.type == 'js' }}
shell: bash
run: echo "SHOULD_RUN=${{ steps.changes.outputs.js == 'true' }}" >> $GITHUB_ENV
- name: set env (functional)
if: ${{ inputs.type == 'functional' }}
shell: bash
run: echo "SHOULD_RUN=${{ steps.changes.outputs.functional == 'true' }}" >> $GITHUB_ENV
- name: set env (visual)
if: ${{ inputs.type == 'visual' }}
shell: bash
run: echo "SHOULD_RUN=${{ steps.changes.outputs.visual == 'true' }}" >> $GITHUB_ENV
- name: set end (all)
if: ${{ inputs.type == 'all' }}
shell: bash
run: echo "SHOULD_RUN=true" >> $GITHUB_ENV
- name: set env (website)
if: ${{ inputs.type == 'website' }}
shell: bash
run: echo "SHOULD_RUN=${{ steps.changes.outputs.website == 'true' }}" >> $GITHUB_ENV
- if: ${{ steps.pr.outputs.mergeable == 'false' && steps.pr.outputs.source_branch != 'main' }}
run: echo "SHOULD_RUN=false" >> $GITHUB_ENV
shell: bash
- name: set output
id: should_run
shell: bash
run: echo "should_run=${{ env.SHOULD_RUN }}" >> $GITHUB_OUTPUT
- uses: "gradio-app/github/actions/commit-status@main"
with:
token: ${{ inputs.token }}
pr: ${{ steps.pr.outputs.pr_number }}
sha: ${{ steps.pr.outputs.sha }}
name: ${{ inputs.name }}
changes: ${{ steps.changes.outputs.changes }}
type: ${{ inputs.type }}
init: true
mergeable: ${{ steps.pr.outputs.source_branch == 'main' || steps.pr.outputs.mergeable }}
commit_status: ${{ inputs.type == 'visual' && steps.should_run.outputs.should_run == 'false' || inputs.commit_status }}