Files
ssh-checkout/action.yml
T
Claude 4fea231b5f Accept ssh-key as a raw PEM key, drop base64 requirement
ssh-key was expected to be base64-encoded and decoded with
`base64 --decode`, which is inconsistent with ssh-upload and
ssh-command (both take the raw PEM directly) and an easy way to end
up with a silently corrupt key file if the stored secret isn't
actually base64. Write the input straight to the key file instead.
2026-08-06 08:51:01 +00:00

69 lines
1.8 KiB
YAML

name: 'Gitea SSH Checkout'
description: 'Clones a repository via SSH on a custom port.'
inputs:
ssh-key:
description: 'Private SSH Key'
required: true
ref:
description: 'Branch, tag, or commit SHA to checkout'
required: false
default: ''
repository:
description: 'Repository to clone (e.g., owner/repo)'
required: false
default: ${{ github.repository }}
host:
description: 'Git server hostname'
required: false
default: 'git.mmquack.nl'
port:
description: 'SSH port'
required: false
default: '2222'
runs:
using: "composite"
steps:
- name: Run SSH Clone
shell: bash # Required for composite actions
env:
SSH_KEY: ${{ inputs.ssh-key }}
REF: ${{ inputs.ref }}
REPO: ${{ inputs.repository }}
HOST: ${{ inputs.host }}
PORT: ${{ inputs.port }}
run: |
# 1. Setup the SSH directory
mkdir -p ~/.ssh
chmod 700 ~/.ssh
# 2. Write the private key to a file as-is
printf '%s\n' "$SSH_KEY" > ~/.ssh/gitea_key
chmod 600 ~/.ssh/gitea_key
# 3. Configure SSH for the custom port and bypass host key prompt
cat >> ~/.ssh/config <<EOF
Host $HOST
Port $PORT
User git
IdentityFile ~/.ssh/gitea_key
StrictHostKeyChecking no
EOF
# 4. Ensure workspace is empty before cloning
cd $GITHUB_WORKSPACE
find . -mindepth 1 -delete
# 5. Clone the repository
echo "Cloning $REPO..."
git clone ssh://git@$HOST:$PORT/$REPO.git .
# 6. Checkout the specific ref
if [ -n "$REF" ]; then
echo "Checking out ref: $REF"
git checkout "$REF"
else
echo "No Ref provided to checkout!"
fi