ci-kit/act/checkout/action.yaml

54 lines
1.8 KiB
YAML
Raw Normal View History

# 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:
server-url:
description: 'Forgejo server URL'
required: true
default: ${{ forgejo.server_url }}
repository:
description: 'Repository path (owner/repo)'
required: true
default: ${{ forgejo.repository }}
ref:
description: 'Commit-ish to checkout'
required: true
default: ${{ forgejo.sha }}
token:
description: 'Forgejo token for authentication'
required: true
default: ${{ forgejo.token }}
git-object-format:
required: true
default: sha256
cwd:
description: 'Create and change working dir before checkout'
required: true
default: '.'
extra-fetch:
description: 'Options line for additional git-fetch after all, e.g. "--unshallow"'
required: false
runs:
using: 'composite'
steps:
- name: Run git checkout commands
shell: bash
run: |
mkdir -vp "${{ inputs.cwd }}"
cd "${{ inputs.cwd }}"
shopt -s dotglob
rm -rf *
git init --object-format=${{ inputs.git-object-format }} -b main .
git remote add origin "${{ inputs.server-url }}/${{ inputs.repository }}.git"
export AH="Authorization: Basic $(printf 'x-access-token:${{ inputs.token }}' | base64 | tr -d '\n')"
git --config-env=http.extraheader=AH fetch --depth 2 origin "${{ inputs.ref }}"
git reset --hard FETCH_HEAD
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
fi