Skip to content

Commit 847a83f

Browse files
committed
auto sync #3
1 parent 29d0de3 commit 847a83f

File tree

1 file changed

+20
-26
lines changed

1 file changed

+20
-26
lines changed
+20-26
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
name: validation-proxy
22

3+
# ::set-output 命令将被弃用,而 env 又不能直接非 steps 的 job 中使用,而 steps 又不支持 uses 使用 action yml 文件……
4+
# 有两种办法:一是使用 job 的 outputs 转发 env ,例如 job 名为 setup 则转发到 needs.setup.outputs(还必须定义 job 的 steps 否则报错),二是直接使用 inputs
5+
36
on:
47
workflow_call:
58
inputs:
@@ -11,41 +14,32 @@ on:
1114
description: "目标(下游)仓库,格式为 owner/repository ,必须指定"
1215
required: true
1316
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+
1926
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 }}"
3227
build:
33-
needs: setup
3428
uses: ./.github/workflows/validation.yml
3529
secrets: inherit
3630
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 }}
3933
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 }}
4135
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 }}
4337
sync:
4438
uses: ./.github/workflows/sync.yml
4539
secrets: inherit
46-
needs: [setup, build]
40+
needs: [build]
4741
with:
4842
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

Comments
 (0)