Skip to content

Commit

Permalink
Add recursive_exclusions option for 7zip - closes #24.
Browse files Browse the repository at this point in the history
  • Loading branch information
TheDoctor0 committed Apr 6, 2022
1 parent 591e9b1 commit 0933661
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
21 changes: 16 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ Default: `.`

The working directory where the zip or tar actually runs.

### `type`
Default: `zip`

Either `zip` or `tar`.

Defines if either a ZIP-file is created, or a tar archive (the latter gzipped).

On Windows platform 7zip is used to zip files as zip command is not available there.

### `exclusions`
Default: none

Expand All @@ -61,12 +70,14 @@ ZIP requires you to specify wildcards or full filenames.

TAR allows you to specify only the filename, no matter if it's in a subdirectory.

### `type`
Default: `zip`
### `recursive_exclusions`
Default: none

Either `zip` or `tar`.
Alternative to `exclusions` that allows you to specify a list of [recursive wildcards](https://sevenzip.osdn.jp/chm/cmdline/switches/recurse.htm).
Only applies to `type: zip` on Windows where 7zip is used.

Defines if either a ZIP-file is created, or a tar archive (the latter gzipped).
For example:

On Windows platform 7zip is used to zip files as zip command is not available there.
```exclusions: *.txt``` will only exclude files ending with `.txt`

```recursive_exclusions: *.txt``` will exclude files ending with `.txt` in any subdirectory.
9 changes: 9 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,23 @@ inputs:
path:
description: 'Base path for archive files'
default: '.'
required: false
directory:
description: 'Working directory before zipping'
default: '.'
required: false
exclusions:
description: 'List of excluded files / directories'
default: ''
required: false
recursive_exclusions:
description: 'List of excluded files / directories with recursive wildcards (only applies on Windows with `zip` type)'
default: ''
required: false
type:
description: 'Tool to use for archiving'
default: 'zip'
required: false
runs:
using: composite
steps:
Expand All @@ -30,6 +38,7 @@ runs:
INPUT_PATH: ${{ inputs.path }}
INPUT_DIRECTORY: ${{ inputs.directory }}
INPUT_EXCLUSIONS: ${{ inputs.exclusions }}
INPUT_RECURSIVE_EXCLUSIONS: ${{ inputs.recursive_exclusions }}
INPUT_TYPE: ${{ inputs.type }}
run: $GITHUB_ACTION_PATH/entrypoint.sh

6 changes: 6 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ then
EXCLUSIONS+=$EXCLUSION
done

for EXCLUSION in $INPUT_RECURSIVE_EXCLUSIONS
do
EXCLUSIONS+=" -xr!"
EXCLUSIONS+=$EXCLUSION
done

7z a -tzip $INPUT_FILENAME $INPUT_PATH $EXCLUSIONS || { printf "\n⛔ Unable to create %s archive.\n" "$INPUT_TYPE"; exit 1; }
fi
else
Expand Down

0 comments on commit 0933661

Please sign in to comment.