forked from lpenz/ghaction-packagecloud
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint
executable file
·53 lines (45 loc) · 1.58 KB
/
entrypoint
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
set -x -e -o pipefail
shopt -s nullglob
if [ -n "$INPUT_USER" ]; then
user_tmp="$INPUT_USER"
elif [ -n "$GITHUB_REPOSITORY" ]; then
user_tmp="${GITHUB_REPOSITORY%%/*}"
fi
user=${user_tmp?Please specify a user}
repository=${INPUT_REPOSITORY?Please specify a repository}
[ -n "$INPUT_DIRECTORY" ] && cd "$INPUT_DIRECTORY"
# "files" array:
if [ -n "$INPUT_FILES" ]; then
# Primitive whitespace splitting
echo Handling input files: "$INPUT_FILES"
INPUT_FILES=$(echo "$INPUT_FILES" | tr '\n' ' ' | tr '\t' ' ' | tr -s ' ')
IFS=" " read -r -a input_file_patterns <<<"$INPUT_FILES"
echo "${input_file_patterns[@]}"
# Parse pattern matching in input files
files=()
for input_file_pattern in "${input_file_patterns[@]}"; do
readarray -d '' _files < <(find $(dirname "${input_file_pattern}") -type f -name "$(basename "${input_file_pattern}")" -print0)
echo Found "${_files[@]}"
echo $(ls -l "${_files[@]}")
files+=("${_files[@]}")
done
else
# Use all debs in current directory
files=(*.deb)
if [ "${#files[@]}" -eq 0 ]; then
# If no debs found in current, dig deeper
readarray -d '' files < <(find . -type f -name '*.deb' -print0)
echo "${files[@]}"
fi
if [ "${#files[@]}" -eq 0 ]; then
# Ok, time to give up
echo No .deb files found >&2
exit 1
fi
fi
# Upload each file separately to support multiple file types
for file in "${files[@]}"; do
echo Pushing "${file}" to "${user}/${repository}"
package_cloud push "${user}/$repository" "${file}" 2>&1
done