From a819335c68ebb88c07f8bcc99c3b3eb21f87e512 Mon Sep 17 00:00:00 2001 From: ange Date: Sun, 8 Jun 2025 06:22:22 +0000 Subject: [PATCH] wip --- action.yaml | 11 +++++++++++ entrypoint.sh | 20 ++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 action.yaml create mode 100755 entrypoint.sh diff --git a/action.yaml b/action.yaml new file mode 100644 index 0000000..867c196 --- /dev/null +++ b/action.yaml @@ -0,0 +1,11 @@ +inputs: + name: + description: 'Artifact name' + path: + description: 'Destination path' + +runs: + using: composite + steps: + - name: download artifacts + run: ${{ gitea.action_path }}/entrypoint.sh diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..f47c4c4 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,20 @@ +#!/bin/bash -e + +curl --fail -v -D /dev/stdout -o resp0.json --header "Authorization: Bearer ${{ inputs.token }}" \ + "${{ gitea.server_url }}/api/actions_pipeline/_apis/pipelines/workflows/${{ gitea.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