Compare commits
10 commits
144f873cb9
...
350f7f8261
Author | SHA1 | Date | |
---|---|---|---|
350f7f8261 | |||
8ff519dba1 | |||
c26c81971e | |||
6c06ed0d6f | |||
e5033a2db8 | |||
0bb308de5f | |||
7fa1147112 | |||
6746229e56 | |||
e844d029c5 | |||
bfaf72b815 |
2 changed files with 29 additions and 22 deletions
|
@ -18,4 +18,4 @@ runs:
|
|||
using: composite
|
||||
steps:
|
||||
- name: Upload
|
||||
run: ${{ gitea.action_path }}/entrypoint.sh
|
||||
run: ${{ forgejo.action_path }}/entrypoint.sh
|
||||
|
|
49
entrypoint.sh
Normal file → Executable file
49
entrypoint.sh
Normal file → Executable file
|
@ -1,24 +1,31 @@
|
|||
#!/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
|
||||
# https://codeberg.org/forgejo/forgejo/src/commit/bf80842b4f14a075c6840b6fe37d59b5ac3fac44/routers/api/actions/artifacts.go
|
||||
|
||||
CURL=(curl -H "Authorization: Bearer $ACTIONS_RUNTIME_TOKEN")
|
||||
|
||||
API="$GITHUB_SERVER_URL/api/actions_pipeline/_apis/pipelines/workflows/$GITHUB_RUN_ID/artifacts?api-version=6.0-preview"
|
||||
|
||||
JSON="$(cat <<EOF
|
||||
{
|
||||
"Type": "actions_storage",
|
||||
"Name": "$INPUT_NAME"
|
||||
}
|
||||
EOF
|
||||
)"
|
||||
UPLOAD_URL="$("${CURL[@]}" --data "$JSON" "$API" | jq -r '.fileContainerResourceUrl')"
|
||||
UPLOAD_URL+="?retentionDays=$INPUT_RETENTION_DAYS"
|
||||
UPLOAD_URL+="&itemPath=$INPUT_NAME%2F$artifact"
|
||||
|
||||
for artifact in $INPUT_PATH; do
|
||||
SIZE=$(stat -c '%s' "$artifact")
|
||||
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
|
||||
rm resp0.json
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue