38 lines
1.4 KiB
YAML
38 lines
1.4 KiB
YAML
name: git-checkout
|
|
description: Clones a Git repository
|
|
inputs:
|
|
# copied from https://github.com/actions/checkout/blob/v7/action.yml
|
|
ref:
|
|
description: >
|
|
The branch, tag or SHA to checkout. When checking out the repository that
|
|
triggered a workflow, this defaults to the reference or SHA for that
|
|
event. Otherwise, uses the default branch.
|
|
runs:
|
|
using: "composite"
|
|
steps:
|
|
- id: git_clone
|
|
shell: bash
|
|
env:
|
|
GIT_REPO_URL: ${{ gitea.server_url }}
|
|
GIT_REPO_USERNAME: ${{ gitea.actor }}
|
|
GIT_REPO_PASSWORD: ${{ gitea.token }}
|
|
GIT_REPO_REF: ${{ inputs.ref }}
|
|
WORKSPACE_PATH: ${{ gitea.workspace }}
|
|
run: |
|
|
GIT_REPO_AUTH_URL=$(echo "${GIT_REPO_URL}" | sed "s~^\(.\+\)://~\1://${GIT_REPO_USERNAME}:${GIT_REPO_PASSWORD}@~")
|
|
if [[ -z ${GIT_REPO_REF} ]]; then
|
|
git clone ${GIT_REPO_AUTH_URL} ${WORKSPACE_PATH}
|
|
else
|
|
git clone -b ${GIT_REPO_REF} --single-branch ${GIT_REPO_AUTH_URL} ${WORKSPACE_PATH}
|
|
fi
|
|
cd
|
|
echo "ref=$(git branch --show-current)" >> $GITHUB_OUTPUT
|
|
echo "commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
|
|
outputs:
|
|
ref:
|
|
description: 'The branch, tag or SHA that was checked out'
|
|
value: ${{ steps.git_clone.outputs.ref }}
|
|
commit:
|
|
description: 'The commit SHA that was checked out'
|
|
value: ${{ steps.git_clone.outputs.commit }}
|