From d4627c8abacbc24ffbaafb00e9cad730504d727c Mon Sep 17 00:00:00 2001 From: Hsdi Date: Sun, 15 Mar 2026 12:27:15 +0800 Subject: [PATCH] 3151227 --- .github/workflows/build-exe.yml | 64 ++++++++++++++++++++++++++++++--- 1 file changed, 59 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-exe.yml b/.github/workflows/build-exe.yml index a6a2fa4..43cea70 100644 --- a/.github/workflows/build-exe.yml +++ b/.github/workflows/build-exe.yml @@ -16,17 +16,71 @@ jobs: runs-on: ubuntu-22.04 steps: - - name: Verify workspace + - name: Checkout repository shell: bash + env: + ACTIONS_TOKEN: ${{ github.token }} + GIT_TERMINAL_PROMPT: 0 run: | pwd ls -la - test -f main.py || { - echo "main.py not found in workspace." - echo "If your runner does not auto-check out the repository, add a local mirror for checkout or clone the repo before running this workflow." - exit 1 + + if [ -f main.py ]; then + echo "Repository already available in workspace." + exit 0 + fi + + if ! command -v git >/dev/null 2>&1; then + sudo apt-get update + sudo apt-get install -y --no-install-recommends git ca-certificates + fi + + repo_url="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git" + + if [ ! -d .git ]; then + git init . + fi + + git config --global --add safe.directory "$PWD" + + if git remote get-url origin >/dev/null 2>&1; then + git remote set-url origin "$repo_url" + else + git remote add origin "$repo_url" + fi + + fetch_target() { + local target="$1" + git fetch --depth=1 origin "$target" } + fetch_with_basic_auth() { + local target="$1" + local username="$2" + local auth_header + auth_header="$(printf '%s:%s' "$username" "${ACTIONS_TOKEN}" | base64 -w0)" + git \ + -c http.extraHeader="Authorization: Basic ${auth_header}" \ + fetch --depth=1 origin "$target" + } + + if fetch_target "${GITHUB_SHA}" || fetch_target "${GITHUB_REF}"; then + echo "Fetched repository without authentication." + elif [ -n "${ACTIONS_TOKEN:-}" ] && (fetch_with_basic_auth "${GITHUB_SHA}" "${GITHUB_ACTOR:-git}" || fetch_with_basic_auth "${GITHUB_REF}" "${GITHUB_ACTOR:-git}"); then + echo "Fetched repository with actor token authentication." + elif [ -n "${ACTIONS_TOKEN:-}" ] && (fetch_with_basic_auth "${GITHUB_SHA}" "oauth2" || fetch_with_basic_auth "${GITHUB_REF}" "oauth2"); then + echo "Fetched repository with oauth2 token authentication." + elif [ -n "${ACTIONS_TOKEN:-}" ] && (fetch_with_basic_auth "${GITHUB_SHA}" "git" || fetch_with_basic_auth "${GITHUB_REF}" "git"); then + echo "Fetched repository with git token authentication." + else + echo "Failed to fetch repository contents from ${repo_url}." + exit 1 + fi + + git checkout --force FETCH_HEAD + git log -1 --oneline + test -f main.py + - name: Setup Wine shell: bash run: |