2026-10-07 12:52:38 +03:00
|
|
|
# SPDX-FileCopyrightText: 2026 Vital A Pi <code@vp.ag>
|
|
|
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
|
name: 'Fast minimalist working copy checkout'
|
|
|
|
|
description: 'No tags, no history, no Node.js'
|
|
|
|
|
|
|
|
|
|
inputs:
|
2026-10-12 11:45:26 +03:00
|
|
|
server-url:
|
2026-10-07 12:52:38 +03:00
|
|
|
description: 'Forgejo server URL'
|
|
|
|
|
required: true
|
|
|
|
|
default: ${{ forgejo.server_url }}
|
|
|
|
|
repository:
|
|
|
|
|
description: 'Repository path (owner/repo)'
|
|
|
|
|
required: true
|
|
|
|
|
default: ${{ forgejo.repository }}
|
2026-10-12 11:45:26 +03:00
|
|
|
ref:
|
|
|
|
|
description: 'Commit-ish to checkout'
|
2026-10-07 12:52:38 +03:00
|
|
|
required: true
|
|
|
|
|
default: ${{ forgejo.sha }}
|
|
|
|
|
token:
|
|
|
|
|
description: 'Forgejo token for authentication'
|
|
|
|
|
required: true
|
|
|
|
|
default: ${{ forgejo.token }}
|
2026-10-12 11:45:26 +03:00
|
|
|
git-object-format:
|
2026-10-07 12:52:38 +03:00
|
|
|
required: true
|
|
|
|
|
default: sha256
|
2026-10-11 13:39:25 +03:00
|
|
|
cwd:
|
|
|
|
|
description: 'Create and change working dir before checkout'
|
|
|
|
|
required: true
|
|
|
|
|
default: '.'
|
2026-10-12 11:45:26 +03:00
|
|
|
extra-fetch:
|
|
|
|
|
description: 'Options line for additional git-fetch after all, e.g. "--unshallow"'
|
|
|
|
|
required: false
|
2026-10-07 12:52:38 +03:00
|
|
|
|
|
|
|
|
runs:
|
|
|
|
|
using: 'composite'
|
|
|
|
|
steps:
|
|
|
|
|
- name: Run git checkout commands
|
|
|
|
|
shell: bash
|
|
|
|
|
run: |
|
2026-10-11 13:39:25 +03:00
|
|
|
mkdir -vp "${{ inputs.cwd }}"
|
|
|
|
|
cd "${{ inputs.cwd }}"
|
2026-10-07 12:52:38 +03:00
|
|
|
shopt -s dotglob
|
|
|
|
|
rm -rf *
|
2026-10-12 11:45:26 +03:00
|
|
|
git init --object-format=${{ inputs.git-object-format }} -b main .
|
|
|
|
|
git remote add origin "${{ inputs.server-url }}/${{ inputs.repository }}.git"
|
2026-10-07 12:52:38 +03:00
|
|
|
export AH="Authorization: Basic $(printf 'x-access-token:${{ inputs.token }}' | base64 | tr -d '\n')"
|
2026-10-12 11:45:26 +03:00
|
|
|
git --config-env=http.extraheader=AH fetch --depth 2 origin "${{ inputs.ref }}"
|
2026-10-07 12:52:38 +03:00
|
|
|
git reset --hard FETCH_HEAD
|
2026-10-12 11:45:26 +03:00
|
|
|
if [[ -n '${{ inputs.extra-fetch }}' ]]; then
|
|
|
|
|
read -r -a a1 <<< '${{ inputs.extra-fetch }}'
|
|
|
|
|
a2=$(printf ' %q' "${a1[@]}")
|
|
|
|
|
printf 'Performing git-fetch with "%s"\n' "$a2"
|
|
|
|
|
git --config-env=http.extraheader=AH fetch $a2
|
2026-10-11 13:39:25 +03:00
|
|
|
fi
|