diff --git a/entrypoint.sh b/entrypoint.sh index a6c6663..bbea49b 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,5 +1,23 @@ #!/usr/bin/env bash +# Check required env variables +flag=0 +if [[ -z "$SLACK_WEBHOOK" ]]; then + flag=1 + missing_secret="SLACK_WEBHOOK" + if [[ -n "$VAULT_ADDR" ]] && [[ -n "$VAULT_TOKEN" ]]; then + flag=0 + fi + if [[ -n "$VAULT_ADDR" ]] || [[ -n "$VAULT_TOKEN" ]]; then + missing_secret="VAULT_ADDR and/or VAULT_TOKEN" + fi +fi + +if [[ "$flag" -eq 1 ]]; then + printf "[\e[0;31mERROR\e[0m] Secret \`$missing_secret\` is missing. Please add it to this action for proper execution.\nRefer https://github.com/rtCamp/action-slack-notify for more information.\n" + exit 1 +fi + # custom path for files to override default files custom_path="$GITHUB_WORKSPACE/.github/slack" main_script="/main.sh" @@ -9,4 +27,4 @@ if [[ -d "$custom_path" ]]; then chmod +x /*.sh fi -bash "$main_script" \ No newline at end of file +bash "$main_script"