diff --git a/.forgejo/workflows/test_workflow.yml b/.forgejo/workflows/test_workflow.yml index 67c7ee7..18aa68e 100644 --- a/.forgejo/workflows/test_workflow.yml +++ b/.forgejo/workflows/test_workflow.yml @@ -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 + - uses: https://codeberg.org/fleg/light-actions/checkout@test1 - 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@test1 + with: + path: test.txt + artifact-name: test-artifact diff --git a/checkout/action.yml b/checkout/action.yml index b3b5947..2844d99 100644 --- a/checkout/action.yml +++ b/checkout/action.yml @@ -1,5 +1,5 @@ name: checkout -description: Checkout the git repository. +description: "Checkout the git repository." runs: using: composite steps: diff --git a/upload-artifact/action.yml b/upload-artifact/action.yml new file mode 100644 index 0000000..8c67705 --- /dev/null +++ b/upload-artifact/action.yml @@ -0,0 +1,48 @@ +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 \ + --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 \ + --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