Files
agent-runtime-framework/harnesses/contexts/gitea-https/v1/init.sh

30 lines
919 B
Bash
Executable File

#!/bin/bash
# Configure git to use GITEA_TOKEN for HTTPS cloning/pushing to gitea.oreillyit.nz
#
# Uses a credential helper script that reads the token from the environment.
# This avoids embedding the token in clone URLs (which would appear in logs).
set -euo pipefail
CRED_HELPER="/opt/harness/contexts/gitea-https/v1/git-credential-gitea.sh"
# Create the credential helper script
cat > "$CRED_HELPER" << 'HELPER_EOF'
#!/bin/bash
# Git credential helper that provides GITEA_TOKEN for gitea.oreillyit.nz
if [ -z "${GITEA_TOKEN:-}" ]; then
exit 1
fi
echo "protocol=https"
echo "host=gitea.oreillyit.nz"
echo "username=token"
echo "password=${GITEA_TOKEN}"
HELPER_EOF
chmod +x "$CRED_HELPER"
# Configure git to use this credential helper for gitea.oreillyit.nz
git config --global credential.https://gitea.oreillyit.nz.helper "$CRED_HELPER"
echo "Git HTTPS credential helper configured for gitea.oreillyit.nz"