name: Upload a Build Artifact description: Upload a build artifact that can be used by subsequent workflow steps inputs: name: description: Artifact name default: artifact path: description: A file, directory or wildcard pattern that describes what to upload required: true retention-days: description: > Duration after which artifact will expire in days. Minimum 1 day. Maximum 90 days unless changed from the repository settings page. runs: using: composite steps: - name: Upload run: | curl --fail -v -D /dev/stdout -o resp0.json --header "Authorization: Bearer ${{ inputs.token }}" \ -X POST --data '{"Type":"actions_storage","Name":"${{ inputs.name }}"}' \ "${{ gitea.server_url }}/api/actions_pipeline/_apis/pipelines/workflows/${{ gitea.run_id }}/artifacts?api-version=6.0-preview" cat resp0.json UPLOAD_URL=$(jq -r '.fileContainerResourceUrl' resp0.json) for artifact in ${{ inputs.path }}; do content_length=$(ls -l "$artifact" | awk '{print $5}') md5=$(openssl md5 -binary "$artifact" | base64) curl --fail -v -D /dev/stdout -o resp1.json --header "Authorization: Bearer ${{ inputs.token }}" \ --header "x-actions-results-md5: $md5" \ --header "x-tfs-filelength: ${content_length}" \ --header "content-range: bytes 0-$((content_length-1))/${content_length}" \ -X PUT --data-binary "@$artifact" \ "${UPLOAD_URL}?retentionDays=${{ inputs.retention-days }}&itemPath=${{ inputs.name }}%2F$artifact" cat resp1.json curl --fail -v -D /dev/stdout -o resp2.json --header "Authorization: Bearer ${{ inputs.token }}" \ -X PATCH \ "${{ gitea.server_url }}/api/actions_pipeline/_apis/pipelines/workflows/${{ gitea.run_id }}/artifacts?api-version=6.0-preview&artifactName=${{ inputs.name }}" cat resp2.json rm resp1.json resp2.json done rm resp0.json