download-artifact/entrypoint.sh
2025-10-22 05:38:48 +00:00

20 lines
1 KiB
Bash
Executable file

#!/bin/bash -e
curl --fail -v -D /dev/stdout -o resp0.json --header "Authorization: Bearer ${{ inputs.token }}" \
"${{ forgejo.server_url }}/api/actions_pipeline/_apis/pipelines/workflows/${{ forgejo.run_id }}/artifacts?api-version=6.0-preview"
cat resp0.json
container_url=$(jq -r '.value.[] | select(.name == "${{ inputs.name }}").fileContainerResourceUrl' resp0.json)
echo $container_url
rm resp0.json
artifact_urlencode=$(echo "${{ inputs.name }}" | jq -Rr '@uri')
echo $artifact_urlencode
curl --fail -v -D /dev/stdout -o resp1.json --header "Authorization: Bearer ${{ inputs.token }}" \
"$container_url?itemPath=$artifact_urlencode"
cat resp1.json
for key in $(jq -r '.value[].path' resp1.json); do
artifact_url=$(jq -r ".value[] | select(.path == \"$key\").contentLocation" resp1.json)
key_urlencode=$(echo $key | jq -Rr '@uri')
curl --fail -v -D /dev/stdout -o "${{ inputs.path }}/$key" --create-dirs --header "Authorization: Bearer ${{ inputs.token }}" \
"$artifact_url?itemPath=$key_urlencode"
done
rm resp1.json