diff --git a/README.md b/README.md index 8563d05..67c85a9 100644 --- a/README.md +++ b/README.md @@ -18,16 +18,16 @@ This plugin assumes that the mapping of "_which Image tag should be deployed to ## Variables -| Variable name | Variable meaning | Example value | -|------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------| -| BRANCH | The branch of the Infrastructure Repo on which to make a commit | `main` | -| GIT_REPO | The (https://) address of the Infrastructure Repo | `https://github.com/myusername/coolrepo` | -| IMAGE_TAG | The Image Tag to insert into a tracking file | `a6b6e8` | -| DESTINATION_FILE | The file in Infrastructure Repo that should be updated to contain `IMAGE_TAG` | `deployed_tags/prod_image_tag` | -| AUTHOR_EMAIL | The email that should be associated with the automated commit | `myname@gmail.com` | -| AUTHOR_NAME | The name that should be associated with the automated commit | `Adam Nonymous` | -| COMMIT_MESSAGE | Commit message. Expands environment variables ([note that](https://docs.drone.io/plugins/overview/#plugin-inputs) any of these variables should have `PLUGIN_` prepended if you are referencing them) | `[Auto] Automated commit to write $PLUGIN_IMAGE_TAG to $PLUGIN_DESTINATION_FILE` | -| ACCESS_TOKEN | Personal Access Token providing access to the Git Repo | | +| Variable name | Required? | Variable meaning | Example value (default value for optional variables) | +|------------------|-----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------| +| BRANCH | No | The branch of the Infrastructure Repo on which to make a commit | `main` | +| AUTHOR_EMAIL | No | The email that should be associated with the automated commit | `auto-update-bot@example.com` | +| AUTHOR_NAME | No | The name that should be associated with the automated commit | `Auto Update Bot` | +| COMMIT_MESSAGE | No | Commit message. Expands environment variables ([note that](https://docs.drone.io/plugins/overview/#plugin-inputs) any of these variables should have `PLUGIN_` prepended if you are referencing them) | `[Auto] Update $DESTINATION_FILE to $IMAGE_TAG` | +| GIT_REPO | Yes | The (https://) address of the Infrastructure Repo | `https://github.com/myusername/coolrepo` | +| IMAGE_TAG | Yes | The Image Tag to insert into a tracking file | `a6b6e8` | +| DESTINATION_FILE | Yes | The file in Infrastructure Repo that should be updated to contain `IMAGE_TAG` | `deployed_tags/prod_image_tag` | +| ACCESS_TOKEN | Yes | Personal Access Token providing access to the Git Repo | | # FAQs diff --git a/script.sh b/script.sh index 1b5544d..65f70a5 100644 --- a/script.sh +++ b/script.sh @@ -2,6 +2,12 @@ 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" .