23 lines
983 B
Bash
23 lines
983 B
Bash
#!/bin/sh
|
|
|
|
set -eox pipefail
|
|
|
|
# Set default values
|
|
PLUGIN_BRANCH="${PLUGIN_BRANCH:=main}"
|
|
PLUGIN_AUTHOR_EMAIL="${PLUGIN_AUTHOR_EMAIL:=auto-update-bot@example.com}"
|
|
PLUGIN_AUTHOR_NAME="${PLUGIN_AUTHOR_NAME:=Auto Update Bot}"
|
|
PLUGIN_COMMIT_MESSAGE="${PLUGIN_COMMIT_MESSAGE:=[Auto] Update $PLUGIN_DESTINATION_FILE to $PLUGIN_IMAGE_TAG}"
|
|
|
|
mkdir /working
|
|
cd /working
|
|
git clone -b "$PLUGIN_BRANCH" "$PLUGIN_GIT_REPO" .
|
|
echo "$PLUGIN_IMAGE_TAG" > "$PLUGIN_DESTINATION_FILE"
|
|
git add "$PLUGIN_DESTINATION_FILE"
|
|
git config user.email "$PLUGIN_AUTHOR_EMAIL"
|
|
git config user.name "$PLUGIN_AUTHOR_NAME"
|
|
# https://stackoverflow.com/a/31926346/1040915
|
|
git commit -m "$(echo $PLUGIN_COMMIT_MESSAGE | envsubst)"
|
|
# https://stackoverflow.com/a/6174447/1040915
|
|
git remote add origin-with-credentials "$(echo $PLUGIN_GIT_REPO | sed -e's,^\(.*://\).*,\1,g')""$PLUGIN_ACCESS_TOKEN@""$(echo $PLUGIN_GIT_REPO | sed -e's,^.*://\(.*\),\1,g')"
|
|
git push origin-with-credentials "$PLUGIN_BRANCH":"$PLUGIN_BRANCH"
|