forked from platypush/platypush
Fabio Manganiello
7fa0dbda7b
A fully self-contained 1.5k LoC Drone file isn't very maintainable, and it makes it hard to reuse parts that are shared across multiple steps (like SSH and git configuration).
30 lines
784 B
Bash
Executable file
30 lines
784 B
Bash
Executable file
#!/bin/sh
|
|
|
|
[ -z "$PGP_KEY" ] && echo "PGP_KEY is not set" && exit 1
|
|
[ -z "$PGP_KEY_ID" ] && echo "PGP_KEY_ID is not set" && exit 1
|
|
|
|
# Install gpg
|
|
if [ -z "$(which gpg)" ]; then
|
|
if [ -n "$(which apt-get)" ]; then
|
|
apt-get update
|
|
apt-get install -y gnupg
|
|
elif [ -n "$(which apk)" ]; then
|
|
apk add --update --no-cache bash gnupg
|
|
elif [ -n "$(which yum)" ]; then
|
|
yum install -y gnupg
|
|
elif [ -n "$(which dnf)" ]; then
|
|
dnf install -y gnupg
|
|
elif [ -n "$(which pacman)" ]; then
|
|
pacman -Sy --noconfirm gnupg
|
|
else
|
|
echo "Could not find a package manager to install gnupg"
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
cat <<EOF | gpg --import --armor
|
|
$PGP_KEY
|
|
EOF
|
|
|
|
git config commit.gpgsign true
|
|
git config user.signingkey "$PGP_KEY_ID"
|