@@ -19,15 +19,16 @@ jobs:
1919 create-package :
2020 runs-on : ubuntu-latest
2121 env :
22- TAG_VERSION : ${{ github.event.release.tag_name }}
22+ TAG_VERSION : ${{ github.event.release.tag_name || github.event.inputs.tag_version }}
2323 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
24- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
24+ GH_TOKEN : ${{ secrets.BOT_TOKEN }} # 使用BOT_TOKEN作为GH_TOKEN
2525 steps :
2626 - name : Checkout code
2727 uses : actions/checkout@v4
2828 with :
2929 fetch-depth : 0
3030 # submodules: "recursive"
31+ token : ${{ secrets.BOT_TOKEN }} # 使用BOT_TOKEN进行checkout
3132
3233 - name : Safe submodule initialization
3334 env :
@@ -38,21 +39,27 @@ jobs:
3839 git config --global user.name "github-actions[bot]"
3940 git config --global user.email "github-actions[bot]@users.noreply.github.com"
4041
41- # 配置Git使用token进行身份验证
42- # git config --global url."https://x-access-token:${GITHUB_TOKEN}@github.com/".insteadOf "https://github.com/"
43- git config --global url."https://x-access-token:${GITHUB_TOKEN}@github.com/".insteadOf " git@github.com:"
42+ # 使用gh命令行工具设置git认证
43+ echo "${{ secrets.BOT_TOKEN }}" | gh auth login --with-token
44+ gh auth setup- git
4445
4546 echo "Checking for submodules..."
4647 if [ -f .gitmodules ]; then
4748 if [ -s .gitmodules ]; then
4849 echo "Initializing submodules..."
49- if git submodule sync --recursive 2>/dev/null; then
50- git submodule update --init --force --recursive || {
51- echo "Warning: Some submodules failed to initialize, continuing anyway..."
52- }
53- else
54- echo "Warning: Submodule sync failed, continuing without submodules..."
55- fi
50+ # 显示子模块配置信息进行调试
51+ echo "Submodule configuration:"
52+ cat .gitmodules
53+
54+ # 尝试使用gh命令克隆子模块
55+ echo "Cloning submodules with gh CLI..."
56+ git submodule foreach --recursive 'GH_TOKEN=${{ secrets.BOT_TOKEN }} gh repo clone $(git config --get remote.origin.url) .'
57+
58+ # 如果上述方法失败,回退到传统方法
59+ git submodule sync --recursive
60+ git -c "credential.helper=!f() { echo username=x-access-token; echo password=${{ secrets.BOT_TOKEN }}; }; f" submodule update --init --force --recursive || {
61+ echo "Warning: Some submodules failed to initialize, continuing anyway..."
62+ }
5663 else
5764 echo ".gitmodules exists but is empty, skipping submodule initialization"
5865 fi
0 commit comments