diff --git a/entrypoint.sh b/entrypoint.sh index 3abdbe8..74b4a64 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,10 +1,9 @@ #!/bin/bash -e -#shellcheck disable=SC2016 -API='${{ gitea.server_url }}/api/actions_pipeline/_apis/pipelines/workflows/${{ gitea.run_id }}/artifacts?api-version=6.0-preview' +API="$GITHUB_SERVER_URL/api/actions_pipeline/_apis/pipelines/workflows/$GITHUB_RUN_ID/artifacts?api-version=6.0-preview" CURL=(curl --fail -v -D/dev/stdout - --header "Authorization: Bearer \${{ inputs.token }}" - --data '{"Type":"actions_storage","Name":"${{ inputs.name }}"}' + --header "Authorization: Bearer $INPUT_TOKEN" + --data '{"Type":"actions_storage","Name":"'"$INPUT_NAME"'"}' ) "${CURL[@]}" -XPOST "$API" -oresp0.json @@ -13,16 +12,16 @@ UPLOAD_URL=$(jq -r '.fileContainerResourceUrl' resp0.json) rm -f resp0.json #shellcheck disable=SC1083 -for artifact in \${{ inputs.path }}; do +for artifact in $INPUT_PATH; do content_length=$(stat -c '%s' "$artifact") md5=$(cksum -amd5 --base64 --untagged "$artifact" | awk '{print $1}') "${CURL[@]}" -XPUT -o resp1.json \ --header "x-actions-results-md5: $md5" \ --header "x-tfs-filelength: $content_length" \ --header "content-range: bytes 0-$((content_length - 1))/$content_length" \ - "$UPLOAD_URL?retentionDays=\${{ inputs.retention-days }}&itemPath=\${{ inputs.name }}%2F$artifact" + "$UPLOAD_URL?retentionDays=$INPUT_RETENTION_DAYS&itemPath=$INPUT_NAME%2F$artifact" cat resp1.json - "${CURL[@]}" -XPATCH -oresp2.json "$API&artifactName=\${{ inputs.name }}" + "${CURL[@]}" -XPATCH -oresp2.json "$API&artifactName=$INPUT_NAME" cat resp2.json rm -f resp1.json resp2.json done