Skip to content

Commit 36f0574

Browse files
committed
isolate upstream #4
1 parent ca33af4 commit 36f0574

File tree

3 files changed

+22
-20
lines changed

3 files changed

+22
-20
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
secrets: inherit
1111
with:
1212
name: "test"
13-
sync:
14-
uses: prototype-test/dist-repo-use-branch_test/.github/workflows/test.yml@main_-_cd_-_test
15-
secrets: inherit
16-
needs: build
13+
# sync:
14+
# uses: prototype-test/dist-repo-use-branch_test/.github/workflows/test.yml@main_-_cd_-_test
15+
# secrets: inherit
16+
# needs: build

.github/workflows/validation-proxy.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ on:
77
required: true
88
type: string
99
env:
10+
main_branch: ${{ github.ref }}
1011
cd_branch_prefix: ${{ github.ref }}_-_cd_-_
1112
dist_branch_prefix: ${{ github.ref }}_-_dist_-_
1213
jobs:
1314
setup:
1415
runs-on: ubuntu-latest
1516
outputs:
1617
# ::set-output 命令将被弃用,而 env 又不能直接在下面非 steps 中使用,而 steps 又不支持 uses 使用 action yml 文件……因此这里转发使用 env
18+
main_branch: ${{ env.main_branch }}
1719
cd_branch_prefix: ${{ env.cd_branch_prefix }}
1820
dist_branch_prefix: ${{ env.dist_branch_prefix }}
1921
steps:
@@ -25,6 +27,7 @@ jobs:
2527
uses: ./.github/workflows/validation.yml
2628
secrets: inherit
2729
with:
30+
main_branch: ${{ needs.setup.outputs.main_branch }}
2831
cd_path: "${{ inputs.name }}/ci"
2932
cd_branch: "${{ needs.setup.outputs.cd_branch_prefix }}${{ inputs.name }}"
3033
dist_path: "${{ inputs.name }}/src"

.github/workflows/validation.yml

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ name: Validation
66
on:
77
workflow_call:
88
inputs:
9+
main_branch: # 上游主分支
10+
required: true
11+
type: string
912
cd_path: # (Github)持续交付路径, 不能以 / 结尾
1013
required: true
1114
type: string
@@ -19,10 +22,6 @@ on:
1922
required: true
2023
type: string
2124

22-
# ref https://docs.github.com/zh/actions/learn-github-actions/variables
23-
env:
24-
main_branch: "main" # 当前仓库(上游)主分支
25-
2625
jobs:
2726
build:
2827
runs-on: ubuntu-latest
@@ -64,7 +63,7 @@ jobs:
6463
if: steps.dist_branch-exists.outputs.branch_exists == 'true'
6564
run: |
6665
# 主分支需要重复使用, 因此基于临时分支操作
67-
git checkout -b temp_${{ env.main_branch }} ${{ env.main_branch }}
66+
git checkout -b temp_${{ inputs.main_branch }} ${{ inputs.main_branch }}
6867
# 创建临时文件夹,如果它不存在的话
6968
mkdir -p $HOME/tmp
7069
# 清空临时文件夹的内容
@@ -78,14 +77,14 @@ jobs:
7877
rsync -a --exclude '.git' $HOME/tmp/ ./
7978
find . -path './.git' -prune -o -exec ls -lR {} +
8079
git add .
81-
git commit -m "🪂 Sync ${{ inputs.dist_path }} from ${{ env.main_branch }} to ${{ inputs.dist_branch }}" || echo "No changes to commit"
80+
git commit -m "🪂 Sync ${{ inputs.dist_path }} from ${{ inputs.main_branch }} to ${{ inputs.dist_branch }}" || echo "No changes to commit"
8281
# 删除临时分支
83-
git branch -D temp_${{ env.main_branch }}
82+
git branch -D temp_${{ inputs.main_branch }}
8483
- name: Sync cd_path from main_branch to exists cd_branch
8584
if: steps.cd_branch-exists.outputs.branch_exists == 'true'
8685
run: |
8786
# 主分支需要重复使用, 因此基于临时分支操作
88-
git checkout -b temp_${{ env.main_branch }} ${{ env.main_branch }}
87+
git checkout -b temp_${{ inputs.main_branch }} ${{ inputs.main_branch }}
8988
# 创建临时文件夹,如果它不存在的话
9089
mkdir -p $HOME/tmp
9190
# 清空临时文件夹的内容
@@ -99,14 +98,14 @@ jobs:
9998
rsync -a --exclude '.git' $HOME/tmp/ ./
10099
find . -path './.git' -prune -o -exec ls -lR {} +
101100
git add .
102-
git commit -m "🪂 Sync ${{ inputs.cd_path }} from ${{ env.main_branch }} to ${{ inputs.cd_branch }}" || echo "No changes to commit"
101+
git commit -m "🪂 Sync ${{ inputs.cd_path }} from ${{ inputs.main_branch }} to ${{ inputs.cd_branch }}" || echo "No changes to commit"
103102
# 删除临时分支
104-
git branch -D temp_${{ env.main_branch }}
103+
git branch -D temp_${{ inputs.main_branch }}
105104
- name: Init dist_branch from dist_path at main_branch
106105
if: steps.dist_branch-exists.outputs.branch_exists == 'false'
107106
run: |
108107
# 主分支需要重复使用, 因此基于临时分支操作
109-
git checkout -b temp_${{ env.main_branch }} ${{ env.main_branch }}
108+
git checkout -b temp_${{ inputs.main_branch }} ${{ inputs.main_branch }}
110109
# 创建临时文件夹,如果它不存在的话
111110
mkdir -p $HOME/tmp
112111
# 清空临时文件夹的内容
@@ -118,14 +117,14 @@ jobs:
118117
git checkout --orphan ${{ inputs.dist_branch }}
119118
rsync -a --exclude '.git' $HOME/tmp/ ./
120119
git add .
121-
git commit -m "🪂 Initial ${{ inputs.dist_path }} from ${{ env.main_branch }} to ${{ inputs.dist_branch }}"
120+
git commit -m "🪂 Initial ${{ inputs.dist_path }} from ${{ inputs.main_branch }} to ${{ inputs.dist_branch }}"
122121
# 删除临时分支
123-
git branch -D temp_${{ env.main_branch }}
122+
git branch -D temp_${{ inputs.main_branch }}
124123
- name: Init cd_branch from cd_path at main_branch
125124
if: steps.cd_branch-exists.outputs.branch_exists == 'false'
126125
run: |
127126
# 主分支需要重复使用, 因此基于临时分支操作
128-
git checkout -b temp_${{ env.main_branch }} ${{ env.main_branch }}
127+
git checkout -b temp_${{ inputs.main_branch }} ${{ inputs.main_branch }}
129128
# 创建临时文件夹,如果它不存在的话
130129
mkdir -p $HOME/tmp
131130
# 清空临时文件夹的内容
@@ -137,9 +136,9 @@ jobs:
137136
git checkout --orphan ${{ inputs.cd_branch }}
138137
rsync -a --exclude '.git' $HOME/tmp/ ./
139138
git add .
140-
git commit -m "🪂 Initial ${{ inputs.cd_path }} from ${{ env.main_branch }} to ${{ inputs.cd_branch }}"
139+
git commit -m "🪂 Initial ${{ inputs.cd_path }} from ${{ inputs.main_branch }} to ${{ inputs.cd_branch }}"
141140
# 删除临时分支
142-
git branch -D temp_${{ env.main_branch }}
141+
git branch -D temp_${{ inputs.main_branch }}
143142
- run: |
144143
git checkout ${{ inputs.dist_branch }}
145144
- name: Push dist_branch

0 commit comments

Comments
 (0)