#!/usr/bin/env bash # Checkout this repo without downloading actions/checkout from GitHub. # act_runner may already have placed sources in the workspace; otherwise # clone from the same Gitea that started the job. set -euo pipefail SERVER="${GITHUB_SERVER_URL:-${GITEA_SERVER_URL:-}}" REPO="${GITHUB_REPOSITORY:-${GITEA_REPOSITORY:-}}" SHA="${GITHUB_SHA:-${GITEA_SHA:-}}" if [[ -f CMakeLists.txt && -d src ]]; then echo "==> workspace already has sources" git rev-parse --short HEAD 2>/dev/null || true exit 0 fi if [[ -z "$SERVER" || -z "$REPO" ]]; then echo "missing GITHUB_SERVER_URL / GITHUB_REPOSITORY" >&2 exit 1 fi echo "==> git clone $SERVER/$REPO" git clone --filter=blob:none "$SERVER/$REPO.git" _ci_src if [[ -n "$SHA" ]]; then git -C _ci_src fetch --depth 1 origin "$SHA" || git -C _ci_src fetch origin "$SHA" git -C _ci_src checkout --force "$SHA" fi # Move into the workspace root (may already contain act_runner metadata). shopt -s dotglob nullglob mv _ci_src/* . rmdir _ci_src 2>/dev/null || rm -rf _ci_src test -f CMakeLists.txt git rev-parse --short HEAD