light-actions/upload-artifact/action.yml

51 lines
2.0 KiB
YAML

name: upload-artifact
description: "Uploads an artifact. Does not compress it or anything - supports just one file."
inputs:
path:
required: true
description: "Path to the file that should be uploaded"
artifact-name:
required: true
description: "Name of the resulting artifact"
runs:
using: composite
steps:
- run: |
set -euxo pipefail
ARTIFACT_BASE="${ACTIONS_RUNTIME_URL}_apis/pipelines/workflows/${GITHUB_RUN_ID}/artifacts?api-version=6.0-preview"
RESOURCE_URL="$(
curl \
-XPOST \
--silent \
--fail-with-body \
${HEADERS} \
--header 'Accept: application/json;api-version=6.0-preview' \
--header 'Authorization: Bearer ${ACTIONS_RUNTIME_TOKEN}' \
--header 'Content-Type: application/json' \
--data '{\"type\": \"actions_storage\", \"name\": \"${{ inputs.artifact-name }}\"}' \
\"$ARTIFACT_BASE\" | jq --exit-status --raw-output .fileContainerResourceUrl
)"
curl \
-XPUT \
--silent \
--fail-with-body \
"${HEADERS}" \
--header 'Accept: application/json;api-version=6.0-preview' \
--header 'Authorization: Bearer ${ACTIONS_RUNTIME_TOKEN}' \
--header 'Content-Type: application/octet-stream' \
--header "Content-Range: bytes 0-$(echo \"$(wc -c < ${{ inputs.path }}) - 1 | wc")/$(wc -c < ${{ inputs.path }})" \
--data-binary "@${{ inputs.path }}" \
"${RESOURCE_URL}?itemPath=${{ inputs.artifact-name }}/$(basename ${{ inputs.path }})"
curl \
-XPATCH \
--silent \
--fail-with-body \
--header 'Accept: application/json;api-version=6.0-preview' \
--header 'Authorization: Bearer ${ACTIONS_RUNTIME_TOKEN}' \
--header 'Content-Type: application/json' \
--data '{"size": 11}' \
"${ARTIFACT_BASE}&artifactName=${{ inputs.artifact-name }}"
shell: sh