From bfaf72b8151db96ef85f1a71c47c8cc19c976f86 Mon Sep 17 00:00:00 2001 From: ange Date: Sat, 1 Feb 2025 14:09:05 +0000 Subject: [PATCH 01/10] chmod --- entrypoint.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 entrypoint.sh diff --git a/entrypoint.sh b/entrypoint.sh old mode 100644 new mode 100755 From e844d029c54bc53e6869e1bc2d62628275977b35 Mon Sep 17 00:00:00 2001 From: ange Date: Sat, 1 Feb 2025 14:11:10 +0000 Subject: [PATCH 02/10] f --- action.yaml | 24 +++++++++++++++++++++++- entrypoint.sh | 24 ------------------------ 2 files changed, 23 insertions(+), 25 deletions(-) delete mode 100755 entrypoint.sh diff --git a/action.yaml b/action.yaml index 9241f54..c26bccd 100644 --- a/action.yaml +++ b/action.yaml @@ -18,4 +18,26 @@ runs: using: composite steps: - name: Upload - run: ${{ gitea.action_path }}/entrypoint.sh + 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 diff --git a/entrypoint.sh b/entrypoint.sh deleted file mode 100755 index 70f5a03..0000000 --- a/entrypoint.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/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 From 6746229e5603ffb728f084b05b83e43f54af00cd Mon Sep 17 00:00:00 2001 From: ange Date: Sat, 1 Feb 2025 14:12:51 +0000 Subject: [PATCH 03/10] fix token --- action.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/action.yaml b/action.yaml index c26bccd..94553a4 100644 --- a/action.yaml +++ b/action.yaml @@ -19,7 +19,7 @@ runs: steps: - name: Upload run: | - curl --fail -v -D /dev/stdout -o resp0.json --header "Authorization: Bearer ${{ inputs.token }}" \ + 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 @@ -27,14 +27,14 @@ runs: 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 }}" \ + 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 ${{ inputs.token }}" \ + 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 From 7fa1147112f0567734c2a4765ba551dddb8c103e Mon Sep 17 00:00:00 2001 From: ange Date: Sat, 1 Feb 2025 14:15:10 +0000 Subject: [PATCH 04/10] 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 From 0bb308de5f7a89afedda7f4037b395c2c1dd0819 Mon Sep 17 00:00:00 2001 From: ange Date: Sat, 1 Feb 2025 14:16:37 +0000 Subject: [PATCH 05/10] chmod --- entrypoint.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 entrypoint.sh diff --git a/entrypoint.sh b/entrypoint.sh old mode 100644 new mode 100755 From e5033a2db83180abefea100c74a9e5ccc6b2f50d Mon Sep 17 00:00:00 2001 From: ange Date: Sat, 1 Feb 2025 14:22:51 +0000 Subject: [PATCH 06/10] fix: $INPUT-S- --- entrypoint.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 70f5a03..4bcbc92 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,11 +1,11 @@ #!/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\"}" \ + -X POST --data "{\"Type\":\"actions_storage\",\"Name\":\"$INPUT_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 +for artifact in $INPUT_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" \ @@ -13,11 +13,11 @@ for artifact in $INPUTS_PATH; do --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" + "${UPLOAD_URL}?retentionDays=$INPUT_RETENTION_DAYS&itemPath=$INPUT_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" + "$GITHUB_SERVER_URL/api/actions_pipeline/_apis/pipelines/workflows/$GITHUB_RUN_ID/artifacts?api-version=6.0-preview&artifactName=$INPUT_NAME" cat resp2.json rm resp1.json resp2.json done From 6c06ed0d6fd802bcbd59484c86e7bb09fbf788aa Mon Sep 17 00:00:00 2001 From: ange Date: Sat, 1 Feb 2025 14:30:51 +0000 Subject: [PATCH 07/10] cleanup --- entrypoint.sh | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 4bcbc92..dc25d36 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,24 +1,18 @@ #!/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\":\"$INPUT_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) +API="$GITHUB_SERVER_URL/api/actions_pipeline/_apis/pipelines/workflows/$GITHUB_RUN_ID/artifacts?api-version=6.0-preview" +CURL=(curl -H "Authorization: Bearer $ACTIONS_RUNTIME_TOKEN") + +UPLOAD_URL="$("${CURL[@]}" --data "{\"Type\":\"actions_storage\",\"Name\":\"$INPUT_NAME\"}" "$API" | jq -r '.fileContainerResourceUrl')" for artifact in $INPUT_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=$INPUT_RETENTION_DAYS&itemPath=$INPUT_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=$INPUT_NAME" - cat resp2.json - rm resp1.json resp2.json + content_length=$(stat -c '%s' "$artifact") + md5=$(openssl md5 -binary "$artifact" | base64) + "${CURL[@]}" -XPUT \ + -H "x-actions-results-md5: $md5" \ + -H "x-tfs-filelength: ${content_length}" \ + -H "content-range: bytes 0-$((content_length-1))/${content_length}" \ + --data-binary "@$artifact" \ + "$UPLOAD_URL?retentionDays=$INPUT_RETENTION_DAYS&itemPath=$INPUT_NAME%2F$artifact" + "${CURL[@]}" -XPATCH \ + "$API&artifactName=$INPUT_NAME" done -rm resp0.json From c26c81971e949c1f99bc5de3b08542c2bff3ee85 Mon Sep 17 00:00:00 2001 From: ange Date: Sat, 1 Feb 2025 14:32:00 +0000 Subject: [PATCH 08/10] cleanup --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index dc25d36..78f9001 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,6 +1,6 @@ #!/bin/bash -e -API="$GITHUB_SERVER_URL/api/actions_pipeline/_apis/pipelines/workflows/$GITHUB_RUN_ID/artifacts?api-version=6.0-preview" +API="$GITHUB_SERVER_URL/api/actions_pipeline/_apis/pipelines/workflows/$GITHUB_RUN_ID/artifacts" CURL=(curl -H "Authorization: Bearer $ACTIONS_RUNTIME_TOKEN") UPLOAD_URL="$("${CURL[@]}" --data "{\"Type\":\"actions_storage\",\"Name\":\"$INPUT_NAME\"}" "$API" | jq -r '.fileContainerResourceUrl')" From 8ff519dba15e1b81198ed267a1227ea623787ad9 Mon Sep 17 00:00:00 2001 From: ange Date: Sat, 1 Feb 2025 15:17:21 +0000 Subject: [PATCH 09/10] cleanup --- entrypoint.sh | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 78f9001..f95fe3b 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,18 +1,31 @@ #!/bin/bash -e -API="$GITHUB_SERVER_URL/api/actions_pipeline/_apis/pipelines/workflows/$GITHUB_RUN_ID/artifacts" +# https://github.com/go-gitea/gitea/blob/47bf8363102b95a240fc6a571d608567ff6b212a/routers/api/actions/artifacts.go + CURL=(curl -H "Authorization: Bearer $ACTIONS_RUNTIME_TOKEN") -UPLOAD_URL="$("${CURL[@]}" --data "{\"Type\":\"actions_storage\",\"Name\":\"$INPUT_NAME\"}" "$API" | jq -r '.fileContainerResourceUrl')" +API="$GITHUB_SERVER_URL/api/actions_pipeline/_apis/pipelines/workflows/$GITHUB_RUN_ID/artifacts?api-version=6.0-preview" + +JSON="$(cat < Date: Wed, 22 Oct 2025 05:39:03 +0000 Subject: [PATCH 10/10] fix: gitea -> forgejo --- action.yaml | 2 +- entrypoint.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/action.yaml b/action.yaml index 9241f54..092026f 100644 --- a/action.yaml +++ b/action.yaml @@ -18,4 +18,4 @@ runs: using: composite steps: - name: Upload - run: ${{ gitea.action_path }}/entrypoint.sh + run: ${{ forgejo.action_path }}/entrypoint.sh diff --git a/entrypoint.sh b/entrypoint.sh index f95fe3b..0fcdede 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,6 +1,6 @@ #!/bin/bash -e -# https://github.com/go-gitea/gitea/blob/47bf8363102b95a240fc6a571d608567ff6b212a/routers/api/actions/artifacts.go +# https://codeberg.org/forgejo/forgejo/src/commit/bf80842b4f14a075c6840b6fe37d59b5ac3fac44/routers/api/actions/artifacts.go CURL=(curl -H "Authorization: Bearer $ACTIONS_RUNTIME_TOKEN")