Skip to content

Commit 0933661

Browse files
committed
Add recursive_exclusions option for 7zip - closes #24.
1 parent 591e9b1 commit 0933661

File tree

3 files changed

+31
-5
lines changed

3 files changed

+31
-5
lines changed

README.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,15 @@ Default: `.`
5050

5151
The working directory where the zip or tar actually runs.
5252

53+
### `type`
54+
Default: `zip`
55+
56+
Either `zip` or `tar`.
57+
58+
Defines if either a ZIP-file is created, or a tar archive (the latter gzipped).
59+
60+
On Windows platform 7zip is used to zip files as zip command is not available there.
61+
5362
### `exclusions`
5463
Default: none
5564

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

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

64-
### `type`
65-
Default: `zip`
73+
### `recursive_exclusions`
74+
Default: none
6675

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

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

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

83+
```recursive_exclusions: *.txt``` will exclude files ending with `.txt` in any subdirectory.

action.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,23 @@ inputs:
1212
path:
1313
description: 'Base path for archive files'
1414
default: '.'
15+
required: false
1516
directory:
1617
description: 'Working directory before zipping'
1718
default: '.'
19+
required: false
1820
exclusions:
1921
description: 'List of excluded files / directories'
2022
default: ''
23+
required: false
24+
recursive_exclusions:
25+
description: 'List of excluded files / directories with recursive wildcards (only applies on Windows with `zip` type)'
26+
default: ''
27+
required: false
2128
type:
2229
description: 'Tool to use for archiving'
2330
default: 'zip'
31+
required: false
2432
runs:
2533
using: composite
2634
steps:
@@ -30,6 +38,7 @@ runs:
3038
INPUT_PATH: ${{ inputs.path }}
3139
INPUT_DIRECTORY: ${{ inputs.directory }}
3240
INPUT_EXCLUSIONS: ${{ inputs.exclusions }}
41+
INPUT_RECURSIVE_EXCLUSIONS: ${{ inputs.recursive_exclusions }}
3342
INPUT_TYPE: ${{ inputs.type }}
3443
run: $GITHUB_ACTION_PATH/entrypoint.sh
3544

entrypoint.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ then
2626
EXCLUSIONS+=$EXCLUSION
2727
done
2828

29+
for EXCLUSION in $INPUT_RECURSIVE_EXCLUSIONS
30+
do
31+
EXCLUSIONS+=" -xr!"
32+
EXCLUSIONS+=$EXCLUSION
33+
done
34+
2935
7z a -tzip $INPUT_FILENAME $INPUT_PATH $EXCLUSIONS || { printf "\n⛔ Unable to create %s archive.\n" "$INPUT_TYPE"; exit 1; }
3036
fi
3137
else

0 commit comments

Comments
 (0)