Skip to content

Commit

Permalink
Added mode and debug parameters.
Browse files Browse the repository at this point in the history
  • Loading branch information
Paebbels committed Dec 25, 2024
1 parent fa51267 commit a556c12
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 13 deletions.
24 changes: 13 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. <br/> Available Options:<br/>  warn: Output a warning but do not fail the action<br/>  error: Fail the action with an error message<br/>  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. <br/> Minimum 1 day.<br/> 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.<br/> The value can range from 0 to 9.<br/> 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.<br/> If false, the action will fail if an artifact for the given name already exists.<br/> 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.<br/> 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. <br/> Available Options:<br/> • warn: Output a warning but do not fail the action<br/> • error: Fail the action with an error message<br/> • 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. <br/> Minimum 1 day.<br/> 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.<br/> The value can range from 0 to 9.<br/> 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.<br/> If false, the action will fail if an artifact for the given name already exists.<br/> 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.<br/> 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:<br/> • tar (default),<br/> • 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'`

Expand Down
51 changes: 49 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -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
Expand Down Expand Up @@ -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 }}
Expand All @@ -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'
Expand All @@ -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 }}

0 comments on commit a556c12

Please sign in to comment.