diff --git a/README.md b/README.md index e711c0d..2007a3c 100644 --- a/README.md +++ b/README.md @@ -46,17 +46,19 @@ jobs: ### Input Parameters -| Parameter | Required | Default | Description | -|------------------------|:--------:|---------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `name` | no | `'artifact'` | Name of the artifact to upload. | -| `working-directory` | no | `''` | | -| `path` | yes | | A list of files, directories or wildcard patterns that describes what to upload. | -| `if-no-files-found` | no | `'warn'` | The desired behavior if no files are found using the provided path.
Available Options:
 warn: Output a warning but do not fail the action
 error: Fail the action with an error message
 ignore: Do not output any warnings or errors, the action does not fail | -| `retention-days` | no | repository settings | Duration after which artifact will expire in days. 0 means using default retention.
Minimum 1 day.
Maximum 90 days unless changed from the repository settings page. | -| `compression-level` | no | `6` | The level of compression for Zlib to be applied to the artifact archive.
The value can range from 0 to 9.
For large files that are not easily compressed, a value of 0 is recommended for significantly faster uploads. | -| `overwrite` | no | `false` | If true, an artifact with a matching name will be deleted before a new one is uploaded.
If false, the action will fail if an artifact for the given name already exists.
Does not fail if the artifact does not exist. | -| `include-hidden-files` | no | `false` | Whether to include hidden files in the provided path in the artifact.
The file contents of any hidden files in the path should be validated before enabled this to avoid uploading sensitive information. | -| `tarball-name` | no | [^1] | | +| Parameter | Required | Default | Description | +|------------------------|:--------:|---------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `name` | no | `'artifact'` | Name of the artifact to upload. | +| `working-directory` | no | `''` | | +| `path` | yes | | A list of files, directories or wildcard patterns that describes what to upload. | +| `if-no-files-found` | no | `'warn'` | The desired behavior if no files are found using the provided path.
Available Options:
 • warn: Output a warning but do not fail the action
 • error: Fail the action with an error message
 • ignore: Do not output any warnings or errors, the action does not fail | +| `retention-days` | no | repository settings | Duration after which artifact will expire in days. 0 means using default retention.
Minimum 1 day.
Maximum 90 days unless changed from the repository settings page. | +| `compression-level` | no | `6` | The level of compression for Zlib to be applied to the artifact archive.
The value can range from 0 to 9.
For large files that are not easily compressed, a value of 0 is recommended for significantly faster uploads. | +| `overwrite` | no | `false` | If true, an artifact with a matching name will be deleted before a new one is uploaded.
If false, the action will fail if an artifact for the given name already exists.
Does not fail if the artifact does not exist. | +| `include-hidden-files` | no | `false` | Whether to include hidden files in the provided path in the artifact.
The file contents of any hidden files in the path should be validated before enabled this to avoid uploading sensitive information. | +| `mode` | no | `'tar'` | Mode of operation. Allowed modes:
 • tar (default),
 • legacy | +| `debug` | no | `false` | Enabled debug mode. List content of the created tarball. | +| `tarball-name` | no | [^1] | Filename of the embedded tarball. | [^1]: `'__pyTooling_upload_artifact__.tar'` diff --git a/action.yml b/action.yml index f7e26f9..4384951 100644 --- a/action.yml +++ b/action.yml @@ -80,14 +80,29 @@ inputs: type: boolean required: false default: false + mode: + description: | + Mode of operation. Allowed modes: tar (default), legacy + type: string + required: false + default: 'tar' + debug: + description: | + Enabled debug mode. List content of the created tarball. + type: boolean + required: false + default: false tarball-name: + description: | + Filename of the embedded tarball. type: string required: false default: '__pyTooling_upload_artifact__.tar' outputs: artifact-id: - description: "GitHub ID of an Artifact, can be used by the REST API" + description: | + GitHub ID of an Artifact, can be used by the REST API. value: ${{ steps.upload.outputs.artifact-id }} artifact-url: description: | @@ -102,8 +117,14 @@ runs: steps: - name: Create tarball from given file patterns id: prepare + if: inputs.mode == 'tar' shell: bash run: | + # Create tarball from given file patterns + printf "::group::List all shell options via 'shopt' ..." + shopt + printf "::endgroup::" + set +e shopt -s globstar @@ -200,9 +221,20 @@ runs: fileCount=$(tar -tf "${tarDirectory}${{ inputs.tarball-name }}" | wc -l) printf "%s\n" "${ANSI_CYAN}Files collected: $fileCount${ANSI_NOCOLOR}" + - name: List content of the generated tarball + id: prepare + if: inputs.mode == 'tar' && inputs.debug == 'true' + shell: bash + run: | + # List content of the generated tarball + set +e + + tar -tvf "${{ inputs.tarball-name }}" + # https://github.com/actions/upload-artifact - - name: Upload artifact + - name: Upload artifact (tarball) id: upload + if: inputs.mode == 'tar' uses: actions/upload-artifact@v4 with: name: ${{ inputs.name }} @@ -215,8 +247,10 @@ runs: - name: Remove temporary tarball id: cleanup + if: inputs.mode == 'tar' shell: bash run: | + # Remove temporary tarball set +e ANSI_LIGHT_RED=$'\x1b[91m' @@ -230,3 +264,16 @@ runs: else printf "%s\n" "${ANSI_LIGHT_GREEN}[OK]${ANSI_NOCOLOR}" fi + + - name: Upload artifact (legacy) + id: upload + if: inputs.mode == 'legacy' + uses: actions/upload-artifact@v4 + with: + name: ${{ inputs.name }} + path: ${{ inputs.path }} + if-no-files-found: ${{ inputs.if-no-files-found }} + retention-days: ${{ inputs.retention-days }} + compression-level: ${{ inputs.compression-level }} + overwrite: ${{ inputs.overwrite }} + include-hidden-files: ${{ inputs.include-hidden-files }}