Compare commits
No commits in common. "350f7f826168512cb282fe2bf4dfe4edad9da27b" and "144f873cb967d955e22cabe87a882dbf032bfd7a" have entirely different histories.
350f7f8261
...
144f873cb9
2 changed files with 22 additions and 29 deletions
|
|
@ -18,4 +18,4 @@ runs:
|
||||||
using: composite
|
using: composite
|
||||||
steps:
|
steps:
|
||||||
- name: Upload
|
- name: Upload
|
||||||
run: ${{ forgejo.action_path }}/entrypoint.sh
|
run: ${{ gitea.action_path }}/entrypoint.sh
|
||||||
|
|
|
||||||
49
entrypoint.sh
Executable file → Normal file
49
entrypoint.sh
Executable file → Normal file
|
|
@ -1,31 +1,24 @@
|
||||||
#!/bin/bash -e
|
#!/bin/bash -e
|
||||||
|
|
||||||
# https://codeberg.org/forgejo/forgejo/src/commit/bf80842b4f14a075c6840b6fe37d59b5ac3fac44/routers/api/actions/artifacts.go
|
curl --fail -v -D /dev/stdout -o resp0.json --header "Authorization: Bearer $ACTIONS_RUNTIME_TOKEN" \
|
||||||
|
-X POST --data "{\"Type\":\"actions_storage\",\"Name\":\"$INPUTS_NAME\"}" \
|
||||||
CURL=(curl -H "Authorization: Bearer $ACTIONS_RUNTIME_TOKEN")
|
"$GITHUB_SERVER_URL/api/actions_pipeline/_apis/pipelines/workflows/$GITHUB_RUN_ID/artifacts?api-version=6.0-preview"
|
||||||
|
cat resp0.json
|
||||||
API="$GITHUB_SERVER_URL/api/actions_pipeline/_apis/pipelines/workflows/$GITHUB_RUN_ID/artifacts?api-version=6.0-preview"
|
UPLOAD_URL=$(jq -r '.fileContainerResourceUrl' resp0.json)
|
||||||
|
for artifact in $INPUTS_PATH; do
|
||||||
JSON="$(cat <<EOF
|
content_length=$(ls -l "$artifact" | awk '{print $5}')
|
||||||
{
|
md5=$(openssl md5 -binary "$artifact" | base64)
|
||||||
"Type": "actions_storage",
|
curl --fail -v -D /dev/stdout -o resp1.json --header "Authorization: Bearer $ACTIONS_RUNTIME_TOKEN" \
|
||||||
"Name": "$INPUT_NAME"
|
--header "x-actions-results-md5: $md5" \
|
||||||
}
|
--header "x-tfs-filelength: ${content_length}" \
|
||||||
EOF
|
--header "content-range: bytes 0-$((content_length-1))/${content_length}" \
|
||||||
)"
|
-X PUT --data-binary "@$artifact" \
|
||||||
UPLOAD_URL="$("${CURL[@]}" --data "$JSON" "$API" | jq -r '.fileContainerResourceUrl')"
|
"${UPLOAD_URL}?retentionDays=$INPUTS_RETENTION_DAYS&itemPath=$INPUTS_NAME%2F$artifact"
|
||||||
UPLOAD_URL+="?retentionDays=$INPUT_RETENTION_DAYS"
|
cat resp1.json
|
||||||
UPLOAD_URL+="&itemPath=$INPUT_NAME%2F$artifact"
|
curl --fail -v -D /dev/stdout -o resp2.json --header "Authorization: Bearer $ACTIONS_RUNTIME_TOKEN" \
|
||||||
|
-X PATCH \
|
||||||
for artifact in $INPUT_PATH; do
|
"$GITHUB_SERVER_URL/api/actions_pipeline/_apis/pipelines/workflows/$GITHUB_RUN_ID/artifacts?api-version=6.0-preview&artifactName=$INPUTS_NAME"
|
||||||
SIZE=$(stat -c '%s' "$artifact")
|
cat resp2.json
|
||||||
MD5=$(openssl md5 -binary "$artifact" | base64)
|
rm resp1.json resp2.json
|
||||||
|
|
||||||
"${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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue