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