Initial upload artifact action
This commit is contained in:
parent
64f3f92456
commit
8079cd6408
|
|
@ -1,10 +1,20 @@
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
checkout:
|
||||||
runs-on: docker
|
runs-on: docker
|
||||||
container:
|
container:
|
||||||
image: git.hswro.org/fleg/actions-experiments:latest
|
image: git.hswro.org/fleg/actions-experiments:latest
|
||||||
steps:
|
steps:
|
||||||
- uses: https://codeberg.org/fleg/light-actions/checkout@main
|
- uses: https://codeberg.org/fleg/light-actions/checkout@main
|
||||||
- run: cat README.md
|
- 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
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
name: checkout
|
name: checkout
|
||||||
description: Checkout the git repository.
|
description: "Checkout the git repository."
|
||||||
runs:
|
runs:
|
||||||
using: composite
|
using: composite
|
||||||
steps:
|
steps:
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
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
|
||||||
|
HEADERS="\
|
||||||
|
--header 'Accept: application/json;api-version=6.0-preview' \
|
||||||
|
--header "Authorization: Bearer $ACTIONS_RUNTIME_TOKEN" \
|
||||||
|
"
|
||||||
|
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 '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 '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 \
|
||||||
|
"${HEADERS}" \
|
||||||
|
--header 'Content-Type: application/json' \
|
||||||
|
--data '{"size": 11}' \
|
||||||
|
"${ARTIFACT_BASE}&artifactName=${{ inputs.artifact-name }}"
|
||||||
|
shell: sh
|
||||||
Loading…
Reference in New Issue