12
12
main_branch : # 上游主分支
13
13
required : true
14
14
type : string
15
- # cd_path: # (Github)持续交付路径, 不能以 / 结尾
16
- # required: true
17
- # type: string
18
- # cd_branch: # 不能包含 / 等字符
19
- # required: true
20
- # type: string
21
15
dist_path : # 分发路径, 不能以 / 结尾
22
16
required : true
23
17
type : string
52
46
echo "branch_exists=false" >> $GITHUB_OUTPUT
53
47
echo "Remote branch ${{ inputs.dist_branch }} does not exist."
54
48
fi
55
- # - name: Check if cd_branch exists in the remote
56
- # id: cd_branch-exists
57
- # run: |
58
- # # grep -qE 使用了 -E 参数来启用扩展的正则表达式, 并且使用了 $ 符号来确保匹配的字符串以 main 结尾, 达到精准匹配的目的
59
- # if git ls-remote --heads origin | grep -qE 'refs/heads/${{ inputs.cd_branch }}$'; then
60
- # echo "branch_exists=true" >> $GITHUB_OUTPUT
61
- # echo "Remote branch ${{ inputs.cd_branch }} exists."
62
- # else
63
- # echo "branch_exists=false" >> $GITHUB_OUTPUT
64
- # echo "Remote branch ${{ inputs.cd_branch }} does not exist."
65
- # fi
49
+
66
50
- name : Sync dist_path from main_branch to exists dist_branch
67
51
if : steps.dist_branch-exists.outputs.branch_exists == 'true'
68
52
run : |
84
68
git commit -m "🪂 Sync ${{ inputs.dist_path }} from ${{ inputs.main_branch }} to ${{ inputs.dist_branch }}" || echo "No changes to commit"
85
69
# 删除临时分支
86
70
git branch -D temp_${{ inputs.main_branch }}
87
- # - name: Sync cd_path from main_branch to exists cd_branch
88
- # if: steps.cd_branch-exists.outputs.branch_exists == 'true'
89
- # run: |
90
- # # 主分支需要重复使用, 因此基于临时分支操作
91
- # git checkout -b temp_${{ inputs.main_branch }} ${{ inputs.main_branch }}
92
- # # 创建临时文件夹,如果它不存在的话
93
- # mkdir -p $HOME/tmp
94
- # # 清空临时文件夹的内容
95
- # find $HOME/tmp/ -mindepth 1 -maxdepth 1 -exec rm -rf {} +
96
- # ls -A $HOME/tmp/
97
- # rsync -a --exclude '.git' ${{ inputs.cd_path }}/ $HOME/tmp/
98
- # ls -A $HOME/tmp/
99
- # git checkout ${{ inputs.cd_branch }}
100
- # # 清空所有文件,除了.git目录
101
- # find . -mindepth 1 -maxdepth 1 ! -name '.git' -exec rm -rf {} +
102
- # rsync -a --exclude '.git' $HOME/tmp/ ./
103
- # find . -path './.git' -prune -o -exec ls -lR {} +
104
- # git add .
105
- # git commit -m "🪂 Sync ${{ inputs.cd_path }} from ${{ inputs.main_branch }} to ${{ inputs.cd_branch }}" || echo "No changes to commit"
106
- # # 删除临时分支
107
- # git branch -D temp_${{ inputs.main_branch }}
71
+
108
72
- name : Init dist_branch from dist_path at main_branch
109
73
if : steps.dist_branch-exists.outputs.branch_exists == 'false'
110
74
run : |
@@ -124,25 +88,7 @@ jobs:
124
88
git commit -m "🪂 Initial ${{ inputs.dist_path }} from ${{ inputs.main_branch }} to ${{ inputs.dist_branch }}"
125
89
# 删除临时分支
126
90
git branch -D temp_${{ inputs.main_branch }}
127
- # - name: Init cd_branch from cd_path at main_branch
128
- # if: steps.cd_branch-exists.outputs.branch_exists == 'false'
129
- # run: |
130
- # # 主分支需要重复使用, 因此基于临时分支操作
131
- # git checkout -b temp_${{ inputs.main_branch }} ${{ inputs.main_branch }}
132
- # # 创建临时文件夹,如果它不存在的话
133
- # mkdir -p $HOME/tmp
134
- # # 清空临时文件夹的内容
135
- # find $HOME/tmp/ -mindepth 1 -maxdepth 1 -exec rm -rf {} +
136
- # rsync -a --exclude '.git' ${{ inputs.cd_path }}/ $HOME/tmp/
137
- # # 清空所有文件,除了.git目录
138
- # find . -mindepth 1 -maxdepth 1 ! -name '.git' -exec rm -rf {} +
139
- # # 创建一个全新的分支, 不基于任何现有的提交
140
- # git checkout --orphan ${{ inputs.cd_branch }}
141
- # rsync -a --exclude '.git' $HOME/tmp/ ./
142
- # git add .
143
- # git commit -m "🪂 Initial ${{ inputs.cd_path }} from ${{ inputs.main_branch }} to ${{ inputs.cd_branch }}"
144
- # # 删除临时分支
145
- # git branch -D temp_${{ inputs.main_branch }}
91
+
146
92
- run : |
147
93
git checkout ${{ inputs.dist_branch }}
148
94
- name : Push dist_branch
@@ -155,15 +101,3 @@ jobs:
155
101
# force_with_lease: true # 仅在远程分支自上次检出以来没有其他提交的情况下成功
156
102
env :
157
103
github_token : ${{ secrets.TOEKN_FOREVER_FULL_WRITE }} # 使用具有完全写入权限的 TOKEN(必须包含 workflows )
158
- # - run: |
159
- # git checkout ${{ inputs.cd_branch }}
160
- # - name: Push cd_branch
161
- # id: push_cd_branch
162
- # uses: ad-m/github-push-action@master
163
- # with:
164
- # repository: ${{ inputs.repository }}
165
- # branch: ${{ inputs.cd_branch }}
166
- # force: true
167
- # # force_with_lease: true # 仅在远程分支自上次检出以来没有其他提交的情况下成功
168
- # env:
169
- # github_token: ${{ secrets.TOEKN_FOREVER_FULL_WRITE }} # 使用具有完全写入权限的 TOKEN(必须包含 workflows )
0 commit comments