This commit is contained in:
@@ -47,7 +47,7 @@ jobs:
|
|||||||
REPO: ${{ github.repository }}
|
REPO: ${{ github.repository }}
|
||||||
REF: ${{ github.ref }}
|
REF: ${{ github.ref }}
|
||||||
SHA: ${{ github.sha }}
|
SHA: ${{ github.sha }}
|
||||||
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
TOKEN: ${{ gitea.token }}
|
||||||
USER_TOKEN: ${{ secrets.token }}
|
USER_TOKEN: ${{ secrets.token }}
|
||||||
run: |
|
run: |
|
||||||
git config --global init.defaultBranch main
|
git config --global init.defaultBranch main
|
||||||
@@ -56,12 +56,13 @@ jobs:
|
|||||||
cd "$GITHUB_WORKSPACE"
|
cd "$GITHUB_WORKSPACE"
|
||||||
git init .
|
git init .
|
||||||
|
|
||||||
# 优先使用 secrets.GITHUB_TOKEN (TOKEN)
|
# 优先使用 gitea.token (TOKEN)
|
||||||
AUTH_TOKEN="$TOKEN"
|
AUTH_TOKEN="$TOKEN"
|
||||||
USE_BASIC_AUTH="false"
|
USE_BASIC_AUTH="false"
|
||||||
|
|
||||||
if [ -n "$TOKEN" ]; then
|
if [ -n "$TOKEN" ]; then
|
||||||
echo "Using secrets.GITHUB_TOKEN for authentication (Bearer Header)."
|
echo "Using gitea.token for authentication (Basic Auth)."
|
||||||
|
USE_BASIC_AUTH="true"
|
||||||
elif [ -n "$USER_TOKEN" ]; then
|
elif [ -n "$USER_TOKEN" ]; then
|
||||||
AUTH_TOKEN="$USER_TOKEN"
|
AUTH_TOKEN="$USER_TOKEN"
|
||||||
USE_BASIC_AUTH="true"
|
USE_BASIC_AUTH="true"
|
||||||
@@ -78,7 +79,7 @@ jobs:
|
|||||||
CLEAN_SERVER=$(echo "$SERVER" | sed -E 's/^\s*.*:\/\///g')
|
CLEAN_SERVER=$(echo "$SERVER" | sed -E 's/^\s*.*:\/\///g')
|
||||||
git fetch --depth=1 "https://$AUTH_TOKEN:x-oauth-basic@$CLEAN_SERVER/$REPO.git" "$REF"
|
git fetch --depth=1 "https://$AUTH_TOKEN:x-oauth-basic@$CLEAN_SERVER/$REPO.git" "$REF"
|
||||||
else
|
else
|
||||||
# 使用 Bearer Token 进行认证 (GITHUB_TOKEN)
|
# 使用 Bearer Token 进行认证
|
||||||
git -c http.extraHeader="Authorization: Bearer $AUTH_TOKEN" fetch --depth=1 "$SERVER/$REPO.git" "$REF"
|
git -c http.extraHeader="Authorization: Bearer $AUTH_TOKEN" fetch --depth=1 "$SERVER/$REPO.git" "$REF"
|
||||||
fi
|
fi
|
||||||
git checkout FETCH_HEAD
|
git checkout FETCH_HEAD
|
||||||
|
|||||||
Reference in New Issue
Block a user