first commit
This commit is contained in:
commit
bca0ff6db5
21
action.yaml
Normal file
21
action.yaml
Normal file
@ -0,0 +1,21 @@
|
||||
name: Upload a Build Artifact
|
||||
description: Upload a build artifact that can be used by subsequent workflow steps
|
||||
|
||||
inputs:
|
||||
name:
|
||||
description: Artifact name
|
||||
default: artifact
|
||||
path:
|
||||
description: A file, directory or wildcard pattern that describes what to upload
|
||||
required: true
|
||||
retention-days:
|
||||
description: >
|
||||
Duration after which artifact will expire in days.
|
||||
Minimum 1 day.
|
||||
Maximum 90 days unless changed from the repository settings page.
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Upload
|
||||
run: ${{ gitea.action_path }}/entrypoint.sh
|
28
entrypoint.sh
Executable file
28
entrypoint.sh
Executable file
@ -0,0 +1,28 @@
|
||||
#!/bin/bash -e
|
||||
#shellcheck disable=SC2016
|
||||
|
||||
API='${{ gitea.server_url }}/api/actions_pipeline/_apis/pipelines/workflows/${{ gitea.run_id }}/artifacts?api-version=6.0-preview'
|
||||
CURL=(curl --fail -v -D/dev/stdout
|
||||
--header "Authorization: Bearer \${{ inputs.token }}"
|
||||
--data '{"Type":"actions_storage","Name":"${{ inputs.name }}"}'
|
||||
)
|
||||
|
||||
"${CURL[@]}" -XPOST "$API" -oresp0.json
|
||||
cat resp0.json
|
||||
UPLOAD_URL=$(jq -r '.fileContainerResourceUrl' resp0.json)
|
||||
rm -f resp0.json
|
||||
|
||||
#shellcheck disable=SC1083
|
||||
for artifact in \${{ inputs.path }}; do
|
||||
content_length=$(stat -c '%s' "$artifact")
|
||||
md5=$(cksum -amd5 --base64 --untagged "$artifact" | awk '{print $1}')
|
||||
"${CURL[@]}" -XPUT -o resp1.json \
|
||||
--header "x-actions-results-md5: $md5" \
|
||||
--header "x-tfs-filelength: $content_length" \
|
||||
--header "content-range: bytes 0-$((content_length - 1))/$content_length" \
|
||||
"$UPLOAD_URL?retentionDays=\${{ inputs.retention-days }}&itemPath=\${{ inputs.name }}%2F$artifact"
|
||||
cat resp1.json
|
||||
"${CURL[@]}" -XPATCH -oresp2.json "$API&artifactName=\${{ inputs.name }}"
|
||||
cat resp2.json
|
||||
rm -f resp1.json resp2.json
|
||||
done
|
Loading…
Reference in New Issue
Block a user