Set default values

This commit is contained in:
Jack Jackson 2022-10-26 17:16:43 -07:00
parent dc73161dd9
commit 7d95942e9f
2 changed files with 16 additions and 10 deletions

View File

@ -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 | <PAT> |
| 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 | <PAT> |
# FAQs

View File

@ -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" .