name: Docker login description: A custom docker login author: Skydust # Define your inputs here. inputs: user: description: The username required: true pass: description: The password or API key required: true default: ${{ gitea.server_url }}/${{ gitea.repository_owner }}/ registry: description: The registry to log onto, defaults to the server required: false default: ${{ gitea.server_url }} runs: using: composite steps: - name: Docker login shell: sh run: | export PREFIXLESS_REGISTRY=$(echo -n "${{ inputs.registry }}" | sed 's/^https\?:\/\///') log_info "$(bold_blue)Checking credentials validity for ${PREFIXLESS_REGISTRY}..." export BASE64_AUTH=$(echo -n "${{ inputs.user }}:${{ inputs.pass }}" | base64 -w 0) response=$(curl -s -w "\n%{http_code}" \ -H "Authorization: Basic $BASE64_AUTH" \ -H "User-Agent: Docker-Client/20.10.12 (linux)" \ "https://${PREFIXLESS_REGISTRY}/v2/") http_code=$(echo "$response" | tail -n 1) response_body=$(echo "$response" | head -n -1) if [ "$http_code" -eq 200 ]; then log_info "$(bold_green)Authentication successful" else log_info "$(bold_red)Authentication failed with HTTP code: $http_code" log_info "$(red)Response body:" log_info "$(red)$response_body" if [ "$http_code" -eq 401 ]; then log_info "$(yellow)The identifiers are probably wrong" fi exit 1 fi echo "Exporting config" echo DOCKER_CONFIG_BASE64=$(echo "{\"auths\": {\"${PREFIXLESS_REGISTRY}\": {\"auth\": \"${BASE64_AUTH}\"}}}" | base64 -w 0) >> $GITEA_ENV