This commit is contained in:
2026-03-15 12:27:15 +08:00
Unverified
parent e59bc51fca
commit d4627c8aba

View File

@@ -16,17 +16,71 @@ jobs:
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
steps: steps:
- name: Verify workspace - name: Checkout repository
shell: bash shell: bash
env:
ACTIONS_TOKEN: ${{ github.token }}
GIT_TERMINAL_PROMPT: 0
run: | run: |
pwd pwd
ls -la ls -la
test -f main.py || {
echo "main.py not found in workspace." if [ -f main.py ]; then
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." echo "Repository already available in workspace."
exit 1 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 - name: Setup Wine
shell: bash shell: bash
run: | run: |