diff --git a/.gitea/workflows/docker-publish.yml b/.gitea/workflows/docker-publish.yml index ac75382..3829b4e 100644 --- a/.gitea/workflows/docker-publish.yml +++ b/.gitea/workflows/docker-publish.yml @@ -17,7 +17,8 @@ jobs: run: | REPO_DIR="repo" SERVER_URL="${GITHUB_SERVER_URL:-$GITEA_SERVER_URL}" - TOKEN="${GITHUB_TOKEN:-$GITEA_TOKEN}" + SERVER_SCHEME="https" + SERVER_HOST="${SERVER_URL}" CLONE_USER="${{ secrets.REGISTRY_USERNAME }}" CLONE_PASS="${{ secrets.REGISTRY_PASSWORD }}" REF_NAME="${GITHUB_REF_NAME}" @@ -30,22 +31,27 @@ jobs: exit 1 fi - rm -rf "${REPO_DIR}" - - if [ -n "${TOKEN}" ]; then - git clone --depth 1 --branch "${REF_NAME}" \ - "https://oauth2:${TOKEN}@${SERVER_URL#https://}/${GITHUB_REPOSITORY}.git" \ - "${REPO_DIR}" - elif [ -n "${CLONE_USER}" ] && [ -n "${CLONE_PASS}" ]; then - git clone --depth 1 --branch "${REF_NAME}" \ - "https://${CLONE_USER}:${CLONE_PASS}@${SERVER_URL#https://}/${GITHUB_REPOSITORY}.git" \ - "${REPO_DIR}" - else - echo "Missing CI token and fallback clone credentials" - echo "Set GITHUB_TOKEN/GITEA_TOKEN or REGISTRY_USERNAME/REGISTRY_PASSWORD secrets" + if [ -z "${CLONE_USER}" ] || [ -z "${CLONE_PASS}" ]; then + echo "Missing REGISTRY_USERNAME or REGISTRY_PASSWORD secret" exit 1 fi + case "${SERVER_URL}" in + http://*) + SERVER_SCHEME="http" + SERVER_HOST="${SERVER_URL#http://}" + ;; + https://*) + SERVER_SCHEME="https" + SERVER_HOST="${SERVER_URL#https://}" + ;; + esac + + rm -rf "${REPO_DIR}" + git clone --depth 1 --branch "${REF_NAME}" \ + "${SERVER_SCHEME}://${CLONE_USER}:${CLONE_PASS}@${SERVER_HOST}/${GITHUB_REPOSITORY}.git" \ + "${REPO_DIR}" + if [ ! -f "${REPO_DIR}/Dockerfile" ]; then echo "Dockerfile not found after clone" exit 1