Compare commits

...

10 commits

Author SHA1 Message Date
350f7f8261
fix: gitea -> forgejo 2025-10-22 05:39:03 +00:00
8ff519dba1
cleanup 2025-02-01 15:17:21 +00:00
c26c81971e
cleanup 2025-02-01 14:32:00 +00:00
6c06ed0d6f
cleanup 2025-02-01 14:30:51 +00:00
e5033a2db8
fix: $INPUT-S- 2025-02-01 14:22:51 +00:00
0bb308de5f
chmod 2025-02-01 14:16:37 +00:00
7fa1147112
binary 2025-02-01 14:15:21 +00:00
6746229e56
fix token 2025-02-01 14:12:51 +00:00
e844d029c5
f 2025-02-01 14:11:10 +00:00
bfaf72b815
chmod 2025-02-01 14:09:05 +00:00
2 changed files with 29 additions and 22 deletions

View file

@ -18,4 +18,4 @@ runs:
using: composite using: composite
steps: steps:
- name: Upload - name: Upload
run: ${{ gitea.action_path }}/entrypoint.sh run: ${{ forgejo.action_path }}/entrypoint.sh

49
entrypoint.sh Normal file → Executable file
View file

@ -1,24 +1,31 @@
#!/bin/bash -e #!/bin/bash -e
curl --fail -v -D /dev/stdout -o resp0.json --header "Authorization: Bearer $ACTIONS_RUNTIME_TOKEN" \ # https://codeberg.org/forgejo/forgejo/src/commit/bf80842b4f14a075c6840b6fe37d59b5ac3fac44/routers/api/actions/artifacts.go
-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" CURL=(curl -H "Authorization: Bearer $ACTIONS_RUNTIME_TOKEN")
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"
for artifact in $INPUTS_PATH; do
content_length=$(ls -l "$artifact" | awk '{print $5}') JSON="$(cat <<EOF
md5=$(openssl md5 -binary "$artifact" | base64) {
curl --fail -v -D /dev/stdout -o resp1.json --header "Authorization: Bearer $ACTIONS_RUNTIME_TOKEN" \ "Type": "actions_storage",
--header "x-actions-results-md5: $md5" \ "Name": "$INPUT_NAME"
--header "x-tfs-filelength: ${content_length}" \ }
--header "content-range: bytes 0-$((content_length-1))/${content_length}" \ EOF
-X PUT --data-binary "@$artifact" \ )"
"${UPLOAD_URL}?retentionDays=$INPUTS_RETENTION_DAYS&itemPath=$INPUTS_NAME%2F$artifact" UPLOAD_URL="$("${CURL[@]}" --data "$JSON" "$API" | jq -r '.fileContainerResourceUrl')"
cat resp1.json UPLOAD_URL+="?retentionDays=$INPUT_RETENTION_DAYS"
curl --fail -v -D /dev/stdout -o resp2.json --header "Authorization: Bearer $ACTIONS_RUNTIME_TOKEN" \ UPLOAD_URL+="&itemPath=$INPUT_NAME%2F$artifact"
-X PATCH \
"$GITHUB_SERVER_URL/api/actions_pipeline/_apis/pipelines/workflows/$GITHUB_RUN_ID/artifacts?api-version=6.0-preview&artifactName=$INPUTS_NAME" for artifact in $INPUT_PATH; do
cat resp2.json SIZE=$(stat -c '%s' "$artifact")
rm resp1.json resp2.json MD5=$(openssl md5 -binary "$artifact" | base64)
"${CURL[@]}" -XPUT \
-H "x-tfs-filelength: $SIZE" \
-H "x-actions-results-md5: $MD5" \
-H "content-range: bytes 0-$((SIZE - 1))/$SIZE" \
--data-binary "@$artifact" \
"$UPLOAD_URL"
"${CURL[@]}" -XPATCH "$API&artifactName=$INPUT_NAME"
done done
rm resp0.json