-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Builds and pushes all images when their source changed.
- Loading branch information
Showing
5 changed files
with
174 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
PATH=".ci:$PATH" | ||
|
||
syntax=plain | ||
if [[ "${1:-}" = "--matrix" ]]; then | ||
syntax=matrix | ||
fi | ||
|
||
images=() | ||
for image in * ;do | ||
if [[ ! -d "${image}" ]]; then | ||
continue | ||
fi | ||
if ! git-changed "$image" &> /dev/null; then | ||
continue | ||
fi | ||
images+=("$image") | ||
done | ||
|
||
if [[ "$syntax" = plain ]]; then | ||
for image in "${images[@]}"; do | ||
echo "$image" | ||
done | ||
elif [[ "$syntax" = matrix ]]; then | ||
output='{"image":[' | ||
first=true | ||
for image in "${images[@]}"; do | ||
if [[ "$first" = true ]]; then | ||
first=false | ||
else | ||
output="$output," | ||
fi | ||
output="$output"'"'"$image"'"' | ||
done | ||
output="$output]}" | ||
echo -n "$output" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
path="${1:-$(pwd)}" | ||
old_ref="origin/master" | ||
new_ref="HEAD" | ||
|
||
if [[ "$(git rev-parse "$old_ref")" = "$(git rev-parse "$new_ref")" ]]; then | ||
old_ref="HEAD~1" | ||
fi | ||
|
||
excluded_patterns=( | ||
'.*/README.md$' | ||
) | ||
|
||
is_excluded() { | ||
local path="$1" | ||
for excl in "${excluded_patterns[@]}"; do | ||
if [[ "${path}" =~ ${excl} ]]; then | ||
return 1 | ||
fi | ||
done | ||
return 0 | ||
} | ||
|
||
filter_excluded() { | ||
while read line; do | ||
if ! is_excluded "$line"; then | ||
echo "$line" | ||
fi | ||
done | ||
} | ||
|
||
git_changed_files() { | ||
local old="$1" | ||
local new="$2" | ||
local path="$3" | ||
git diff --name-only "$old..$new" -- "$path" | ||
} | ||
|
||
mapfile -t changed_files < <(git_changed_files "$old_ref" "$new_ref" "$path" | filter_excluded) | ||
|
||
if [[ ${#changed_files[@]} == 0 ]]; then | ||
echo "Nothing changed." | ||
exit 1 | ||
else | ||
echo "Changes:" | ||
for file in "${changed_files[@]}"; do | ||
echo " $file" | ||
done | ||
exit 0 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
path="$1" | ||
tags_path="$path/tags" | ||
|
||
if [[ ! -f "$tags_path" ]]; then | ||
echo "$tags_path does not exist" | ||
exit 1 | ||
fi | ||
|
||
output='"' | ||
first=true | ||
for tag in $(<"$tags_path"); do | ||
if [[ "$first" = true ]]; then | ||
first=false | ||
output="$output$tag" | ||
else | ||
output="$output\n$tag" | ||
fi | ||
done | ||
output="$output"'"' | ||
echo -n "$output" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
hdivsecurity/clang-format:latest | ||
hdivsecurity/clang-format:10 |