Skip to content

Commit 9d7ae3b

Browse files
authored
v1.3.2
2 parents 6172cee + 11bc8c5 commit 9d7ae3b

File tree

2 files changed

+36
-9
lines changed

2 files changed

+36
-9
lines changed

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ is not implemented by GitHub until now (requested on [05.12.2019](https://github
66
and still delayed and/or refused? to be implemented in the future. According to GitHub, the internal API doesn't allow
77
the implementation of such a feature, but this actions is demonstrating a working solution.
88

9+
See [pyTooling/download-artifact](https://github.com/pyTooling/download-artifact) for the matching download action.
10+
911

1012
## Usage
1113

@@ -53,7 +55,7 @@ jobs:
5355

5456
| Parameter | Description |
5557
|----------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
56-
| `artifact-id` | GitHub ID of an Artifact, can be used by the REST API |
58+
| `artifact-id` | GitHub ID of an Artifact, can be used by the REST API. |
5759
| `artifact-url` | URL to download an Artifact. Can be used in many scenarios such as linking to artifacts in issues or pull requests. Users must be logged-in in order for this URL to work. This URL is valid as long as the artifact has not expired or the artifact, run or repository have not been deleted. |
5860

5961

@@ -78,6 +80,9 @@ This action uses `tar` as provided by the GitHub runner's operating system image
7880
To ensure files starting with a dash aren't considered command line options to `tar`, `tar` is called with
7981
`--verbatim-files-from` option.
8082

83+
To ensure files are extracted and assigned to the owner/group of the extracting user, options `--owner=0` and
84+
`--group=0` are used when creating the tarball.
85+
8186

8287
### On macOS (BSD tar)
8388

@@ -93,18 +98,30 @@ as a command line option.
9398
>
9499
> Source: https://man.freebsd.org/cgi/man.cgi?tar(1)
95100

101+
⚠ BSD tar doesn't support a `--owner=0` and `--group=0` option.
102+
96103

97104
### On Windows (GNU tar)
98105

99106
To ensure files starting with a dash aren't considered command line options to `tar`, `tar` is called with
100107
`--verbatim-files-from` option.
101108

109+
To ensure files are extracted and assigned to the owner/group of the extracting user, options `--owner=0` and
110+
`--group=0` are used when creating the tarball.
111+
102112

103113
## Dependencies
104114

105115
* [actions/upload-artifact@v4](https://github.com/actions/upload-artifact)
106116

107117

118+
## Competing Actions
119+
120+
* [eviden-actions/upload-artifact](https://github.com/eviden-actions/upload-artifact)
121+
* [nmerget/upload-gzip-artifact](https://github.com/nmerget/upload-gzip-artifact)
122+
* [alehechka/upload-tartifact](https://github.com/alehechka/upload-tartifact)
123+
124+
108125
## Contributors
109126

110127
* [Patrick Lehmann](https://GitHub.com/Paebbels) (Maintainer)

action.yml

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ author: Patrick Lehmann (@Paebbels)
2323

2424
inputs:
2525
name:
26-
description: |
26+
description: |
2727
Name of the artifact to upload.
2828
type: string
2929
required: false
@@ -120,7 +120,7 @@ runs:
120120
exit 1
121121
else
122122
echo -e "${ANSI_LIGHT_GREEN}[OK]${ANSI_NOCOLOR}"
123-
123+
124124
dir="${{ inputs.working-directory }}"
125125
tarDirectory=""
126126
while [[ "${dir}" != "." ]]; do
@@ -146,35 +146,45 @@ runs:
146146
PATTERNS+=("$pattern")
147147
done <<<'${{ inputs.path }}'
148148
echo -e "${ANSI_LIGHT_GREEN}[DONE]${ANSI_NOCOLOR}"
149-
149+
150150
print_files_unique() {
151151
for i in "$@"; do
152152
compgen -G "$i" || true
153153
done | sort | uniq
154154
}
155-
155+
156156
echo -e "Checking tar ($(which tar)): ${ANSI_CYAN}$(tar --version | head -n 1)${ANSI_NOCOLOR}"
157157
echo -n "Assemble OS specific tar command line options ... "
158158
if [[ "${{ runner.os }}" == "macOS" ]]; then
159159
echo -e "${ANSI_Y}[macOS]${ANSI_NOCOLOR}"
160+
161+
# Options for BSD tar
162+
tarOptions=()
163+
164+
# Option to read filenames from file
160165
filesFrom=("-T")
161166
elif [[ "${{ runner.os }}" == "Linux" || "${{ runner.os }}" == "Windows" ]]; then
162167
echo -e "${ANSI_LIGHT_GREEN}[${{ runner.os }}]${ANSI_NOCOLOR}"
168+
169+
# Options for GNU tar
170+
tarOptions=("--owner=0" "--group=0")
171+
172+
# Option to read filenames from file
163173
filesFrom=("--verbatim-files-from" "--files-from")
164174
else
165175
echo -e "${ANSI_LIGHT_RED}[UNSUPPORTED]${ANSI_NOCOLOR}"
166176
exit 1
167177
fi
168-
178+
169179
echo -n "Creating temporary tarball '${tarDirectory}${{ inputs.tarball-name }}' ... "
170-
tar -cf "${tarDirectory}${{ inputs.tarball-name }}" --owner=0 --group=0 "${filesFrom[@]}" <(print_files_unique "${PATTERNS[@]}")
180+
tar -cf "${tarDirectory}${{ inputs.tarball-name }}" "${tarOptions[@]}" "${filesFrom[@]}" <(print_files_unique "${PATTERNS[@]}")
171181
if [[ $? -ne 0 ]]; then
172182
echo -e "${ANSI_LIGHT_RED}[FAILED]${ANSI_NOCOLOR}"
173183
exit 1
174184
else
175185
echo -e "${ANSI_LIGHT_GREEN}[OK]${ANSI_NOCOLOR}"
176186
fi
177-
187+
178188
echo -e "${ANSI_CYAN}Files collected: $(tar -tf "${tarDirectory}${{ inputs.tarball-name }}" | wc -l)${ANSI_NOCOLOR}"
179189
180190
# https://github.com/actions/upload-artifact
@@ -199,7 +209,7 @@ runs:
199209
ANSI_LIGHT_RED="\e[91m"
200210
ANSI_LIGHT_GREEN="\e[92m"
201211
ANSI_NOCOLOR="\e[0m"
202-
212+
203213
echo -n "Removing temporary tarball ... "
204214
rm -f "${{ inputs.tarball-name }}"
205215
if [[ $? -ne 0 ]]; then

0 commit comments

Comments
 (0)