Initial upload artifact action
/ checkout (push) Successful in 2s Details
/ upload-artifact (push) Failing after 2s Details

This commit is contained in:
Michał Rudowicz 2025-02-25 19:38:26 +01:00
parent 64f3f92456
commit 29bf9a6f9c
3 changed files with 62 additions and 2 deletions

View File

@ -1,10 +1,20 @@
on:
push:
jobs:
test:
checkout:
runs-on: docker
container:
image: git.hswro.org/fleg/actions-experiments:latest
steps:
- uses: https://codeberg.org/fleg/light-actions/checkout@main
- run: cat README.md
upload-artifact:
runs-on: docker
container:
image: git.hswro.org/fleg/actions-experiments:latest
steps:
- run: echo "test passed" > test.txt
- uses: https://codeberg.org/fleg/light-actions/upload-artifact@main
with:
path: test.txt
artifact-name: test-artifact

View File

@ -1,5 +1,5 @@
name: checkout
description: Checkout the git repository.
description: "Checkout the git repository."
runs:
using: composite
steps:

View File

@ -0,0 +1,50 @@
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