1
1
name : validation-proxy
2
2
3
+ # ::set-output 命令将被弃用,而 env 又不能直接非 steps 的 job 中使用,而 steps 又不支持 uses 使用 action yml 文件……
4
+ # 有两种办法:一是使用 job 的 outputs 转发 env ,例如 job 名为 setup 则转发到 needs.setup.outputs(还必须定义 job 的 steps 否则报错),二是直接使用 inputs
5
+
3
6
on :
4
7
workflow_call :
5
8
inputs :
11
14
description : " 目标(下游)仓库,格式为 owner/repository ,必须指定"
12
15
required : true
13
16
type : string
14
- env :
15
- repository : prototype-validation/dist-repo-use-branch_upstream # 可以指定独立的仓库,也可以使用 ${{ github.repository }}
16
- main_branch : ${{ github.ref }} # 如果指定了独立的仓库且主分支与当前仓库不一致则需要指定主分支,如果一致则可用 ${{ github.ref }}
17
- cd_branch_prefix : ${{ github.ref }}_-_cd_-_ # 如果指定了独立的仓库且主分支与当前仓库不一致则需要指定分支前缀的前缀,如果一致则可用 ${{ github.ref }}
18
- dist_branch_prefix : ${{ github.ref }}_-_dist_-_ # 如果指定了独立的仓库且主分支与当前仓库不一致则需要指定分支前缀的前缀,如果一致则可用 ${{ github.ref }}
17
+ main_branch :
18
+ description : " 目标(下游)仓库主分支名"
19
+ default : main
20
+ type : string
21
+ upstream_repository : # 上游仓库
22
+ description : " 上游仓库, 格式为 owner/repository ,不指定则默认为当前仓库"
23
+ default : prototype-validation/dist-repo-use-branch_upstream # ${{ github.repository }}
24
+ type : string
25
+
19
26
jobs :
20
- setup :
21
- runs-on : ubuntu-latest
22
- outputs :
23
- # ::set-output 命令将被弃用,而 env 又不能直接在下面非 steps 中使用,而 steps 又不支持 uses 使用 action yml 文件……因此这里转发使用 env
24
- repository : ${{ env.repository }}
25
- main_branch : ${{ env.main_branch }}
26
- cd_branch_prefix : ${{ env.cd_branch_prefix }}
27
- dist_branch_prefix : ${{ env.dist_branch_prefix }}
28
- steps :
29
- - id : nothing-step
30
- run : |
31
- echo "这一步是必要的,去掉会报错。env.repository=${{ env.repository }}"
32
27
build :
33
- needs : setup
34
28
uses : ./.github/workflows/validation.yml
35
29
secrets : inherit
36
30
with :
37
- repository : ${{ needs.setup.outputs.repository }}
38
- main_branch : ${{ needs.setup.outputs .main_branch }}
31
+ repository : ${{ inputs.upstream_repository }}
32
+ main_branch : ${{ inputs .main_branch }}
39
33
cd_path : ${{ inputs.name }}/ci
40
- cd_branch : ${{ needs.setup.outputs.cd_branch_prefix }}${{ inputs.name }}
34
+ cd_branch : ${{ inputs.main_branch }}_-_cd_-_ ${{ inputs.name }}
41
35
dist_path : ${{ inputs.name }}/src
42
- dist_branch : ${{ needs.setup.outputs.dist_branch_prefix }}${{ inputs.name }}
36
+ dist_branch : ${{ inputs.main_branch }}_-_dist_-_ ${{ inputs.name }}
43
37
sync :
44
38
uses : ./.github/workflows/sync.yml
45
39
secrets : inherit
46
- needs : [setup, build]
40
+ needs : [build]
47
41
with :
48
42
target_sync_repo : ${{ inputs.repo_name }}
49
- target_sync_branch : ${{ needs.setup.outputs .main_branch }}
50
- upstream_sync_branch : ${{ needs.setup.outputs.dist_branch_prefix }}${{ inputs.name }}
51
- upstream_sync_repo : ${{ needs.setup.outputs.repository }}
43
+ target_sync_branch : ${{ inputs .main_branch }}
44
+ upstream_sync_branch : ${{ inputs.main_branch }}_-_dist_-_ ${{ inputs.name }}
45
+ upstream_sync_repo : ${{ inputs.upstream_repository }}
0 commit comments