From 7fa1147112f0567734c2a4765ba551dddb8c103e Mon Sep 17 00:00:00 2001 From: ange Date: Sat, 1 Feb 2025 14:15:10 +0000 Subject: [PATCH] binary --- action.yaml | 24 +----------------------- entrypoint.sh | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 23 deletions(-) create mode 100644 entrypoint.sh diff --git a/action.yaml b/action.yaml index 94553a4..9241f54 100644 --- a/action.yaml +++ b/action.yaml @@ -18,26 +18,4 @@ runs: using: composite steps: - name: Upload - run: | - curl --fail -v -D /dev/stdout -o resp0.json --header "Authorization: Bearer $ACTIONS_RUNTIME_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 $ACTIONS_RUNTIME_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 $ACTIONS_RUNTIME_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 + run: ${{ gitea.action_path }}/entrypoint.sh diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..70f5a03 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,24 @@ +#!/bin/bash -e + +curl --fail -v -D /dev/stdout -o resp0.json --header "Authorization: Bearer $ACTIONS_RUNTIME_TOKEN" \ + -X POST --data "{\"Type\":\"actions_storage\",\"Name\":\"$INPUTS_NAME\"}" \ + "$GITHUB_SERVER_URL/api/actions_pipeline/_apis/pipelines/workflows/$GITHUB_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 $ACTIONS_RUNTIME_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 $ACTIONS_RUNTIME_TOKEN" \ + -X PATCH \ + "$GITHUB_SERVER_URL/api/actions_pipeline/_apis/pipelines/workflows/$GITHUB_RUN_ID/artifacts?api-version=6.0-preview&artifactName=$INPUTS_NAME" + cat resp2.json + rm resp1.json resp2.json +done +rm resp0.json