From 74750bd10b541a5ef9bfb535bc49565366b73994 Mon Sep 17 00:00:00 2001 From: yigid balaban Date: Fri, 15 Aug 2025 19:26:20 +0300 Subject: [PATCH] Update action.yml --- action.yml | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/action.yml b/action.yml index a606a03..8a58846 100644 --- a/action.yml +++ b/action.yml @@ -2,24 +2,51 @@ name: checkout description: Node-free checkout for Gitea Actions using preinstalled git. inputs: ref: - description: Branch, tag, or commit to fetch (defaults to current workflow commit) + description: Branch, tag, or commit to fetch (defaults to current commit) required: false default: "" + skip_ssl_verify: + description: "true to disable SSL certificate verification (for edge cases)" + required: false + default: "false" runs: using: composite steps: - shell: sh env: - TOKEN: ${{ github.token }} + TOKEN: ${{ github.token || env.GITEA_TOKEN }} REPO: ${{ github.repository }} REF: ${{ inputs.ref || github.sha }} SERVER_URL: ${{ github.server_url }} + SKIP_SSL: ${{ inputs.skip_ssl_verify }} run: | set -euo pipefail + + # Check that we have a token + if [ -z "$TOKEN" ]; then + echo "❌ No repository token found (GITHUB_TOKEN or GITEA_TOKEN)." + exit 1 + fi + BASE="${SERVER_URL:-${GITEA_SERVER_URL:-}}" - [ -n "$BASE" ] || { echo "Missing server_url"; exit 1; } + if [ -z "$BASE" ]; then + echo "❌ Missing server_url (SERVER_URL or GITEA_SERVER_URL)." + exit 1 + fi + + # Create repo and set remote git init "$GITHUB_WORKSPACE" cd "$GITHUB_WORKSPACE" git remote add origin "${BASE%/}/${REPO}.git" - git -c http.extraHeader="Authorization: token $TOKEN" fetch --depth=1 origin "$REF" - git checkout FETCH_HEAD + + # Handle SSL verification setting + GIT_SSL_OPT="" + if [ "$SKIP_SSL" = "true" ]; then + echo "⚠️ SSL verification disabled for git fetch." + GIT_SSL_OPT="-c http.sslVerify=false" + fi + + # Fetch and checkout + git -c http.extraHeader="Authorization: token $TOKEN" $GIT_SSL_OPT \ + fetch --depth=1 origin "$REF" + git checkout FETCH_HEAD \ No newline at end of file