Last active
June 29, 2020 11:55
-
-
Save andreineculau/a267bc5e2f64487f5812d24a56aa2283 to your computer and use it in GitHub Desktop.
git-filter for codeship jet command (doesn't work because 'jet encrypt' is not deterministic)
This file contains hidden or 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
# NOTE .git/config not .git-config, but github gist doesn't allow slash | |
[filter "jet"] | |
clean = \"$(git rev-parse --git-common-dir)\"/../git-filter-jet-clean %f | |
smudge = \"$(git rev-parse --git-common-dir)\"/../git-filter-jet-smudge | |
required = true | |
[diff "jet"] | |
textconv = \"$(git rev-parse --git-common-dir)\"/../git-filter-jet-textconv | |
cachetextconv = true | |
binary = true |
This file contains hidden or 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
/codeship-env/*.encrypted filter=jet diff=jet |
This file contains hidden or 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
#!/usr/bin/env bash | |
filename=$1 | |
tempfile=$(mktemp 2>/dev/null || mktemp -t tmp) | |
tempfile2=$(mktemp 2>/dev/null || mktemp -t tmp) | |
trap 'rm -f "$tempfile" "$tempfile2"' EXIT | |
tee "$tempfile" &>/dev/null | |
if [[ -s $filename ]]; then | |
read -n 11 firstbytes <"$tempfile" | |
if [[ $firstbytes == "codeship:v2" ]]; then | |
cat "$tempfile" | |
elif [[ ! -e codeship.aes ]]; then | |
cat "$tempfile" | |
else | |
jet encrypt "$filename" "$tempfile2" | |
cat "$tempfile2" | |
fi | |
fi |
This file contains hidden or 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
#!/usr/bin/env bash | |
filename=$1 | |
tempfile=$(mktemp 2>/dev/null || mktemp -t tmp) | |
tempfile2=$(mktemp 2>/dev/null || mktemp -t tmp) | |
trap 'rm -f "$tempfile" "$tempfile2"' EXIT | |
tee "$tempfile" &>/dev/null | |
read -n 11 firstbytes <"$tempfile" | |
if [[ $firstbytes != "codeship:v2" ]]; then | |
cat "$tempfile" | |
elif [[ ! -e codeship.aes ]]; then | |
cat "$tempfile" | |
else | |
jet decrypt "$tempfile" "$tempfile2" | |
cat "$tempfile2" | |
fi |
This file contains hidden or 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
#!/usr/bin/env bash | |
filename=$1 | |
tempfile=$(mktemp 2>/dev/null || mktemp -t tmp) | |
tempfile2=$(mktemp 2>/dev/null || mktemp -t tmp) | |
trap 'rm -f "$tempfile" "$tempfile2"' EXIT | |
cat "$filename" | tee "$tempfile" &>/dev/null | |
if [[ -s $filename ]]; then | |
if [[ ! -e codeship.aes ]]; then | |
cat "$tempfile" | |
else | |
jet decrypt "$tempfile" "$tempfile2" | |
cat "$tempfile2" | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment