Update action.yml
This commit is contained in:
37
action.yml
37
action.yml
@@ -2,24 +2,51 @@ name: checkout
|
|||||||
description: Node-free checkout for Gitea Actions using preinstalled git.
|
description: Node-free checkout for Gitea Actions using preinstalled git.
|
||||||
inputs:
|
inputs:
|
||||||
ref:
|
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
|
required: false
|
||||||
default: ""
|
default: ""
|
||||||
|
skip_ssl_verify:
|
||||||
|
description: "true to disable SSL certificate verification (for edge cases)"
|
||||||
|
required: false
|
||||||
|
default: "false"
|
||||||
runs:
|
runs:
|
||||||
using: composite
|
using: composite
|
||||||
steps:
|
steps:
|
||||||
- shell: sh
|
- shell: sh
|
||||||
env:
|
env:
|
||||||
TOKEN: ${{ github.token }}
|
TOKEN: ${{ github.token || env.GITEA_TOKEN }}
|
||||||
REPO: ${{ github.repository }}
|
REPO: ${{ github.repository }}
|
||||||
REF: ${{ inputs.ref || github.sha }}
|
REF: ${{ inputs.ref || github.sha }}
|
||||||
SERVER_URL: ${{ github.server_url }}
|
SERVER_URL: ${{ github.server_url }}
|
||||||
|
SKIP_SSL: ${{ inputs.skip_ssl_verify }}
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
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:-}}"
|
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"
|
git init "$GITHUB_WORKSPACE"
|
||||||
cd "$GITHUB_WORKSPACE"
|
cd "$GITHUB_WORKSPACE"
|
||||||
git remote add origin "${BASE%/}/${REPO}.git"
|
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
|
||||||
Reference in New Issue
Block a user