Files
checkout/action.yml
2025-08-15 19:13:51 +03:00

26 lines
857 B
YAML

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)
required: false
default: ""
runs:
using: composite
steps:
- shell: sh
env:
TOKEN: ${{ github.token }}
REPO: ${{ github.repository }}
REF: ${{ inputs.ref || github.sha }}
SERVER_URL: ${{ github.server_url }}
run: |
set -euo pipefail
BASE="${SERVER_URL:-${GITEA_SERVER_URL:-}}"
[ -n "$BASE" ] || { echo "Missing server_url"; exit 1; }
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