You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My team used this action as inspiration but added the ability to close an issue, I can open a PR with the following if yall would like.
#!/usr/bin/env bash
set -ex
if [ $# -lt 1 ]; then
echo "No arguments provided"
echo "Provide an environment"
exit 1
fi
alias=${1}
action=${2}
# Make sure an alias was defined
if [[ -z "${ALIAS}" ]]; then
echo "ERROR: No alert alias was set while attempting to generate OpsGenie alert"
exit 2;
fi
# Make sure an action was defined
if [ "$action" != "open" ] && [ "$action" != "close" ]; then
echo "Invalid action, should be open or close"
exit 1
fi
if [ "$action" = "open" ]; then
priority=${3}
message=${4}
# Make sure an acceptable priority level was defined
if [[ "P1" != "${priority}" ]] && [[ "P2" != "${priority}" ]] && [[ "P3" != "${priority}" ]] && [[ "P4" != "${priority}" ]] && [[ "P5" != "${priority}" ]]; then
echo "ERROR: An invalid alert priority level (${priority}) was set, it must be one of the valid OpsGenie alert levels (P1-P5)"
exit 3;
fi
# Make sure a message was defined
if [[ -z "${message}" ]]; then
echo "ERROR: No alert message was set while attempting to generate OpsGenie alert"
exit 1;
fi
curl -X POST https://api.opsgenie.com/v2/alerts \
-H "Content-Type: application/json" \
-H "Authorization: GenieKey ${OPSGENIE_API_KEY}" \
-d \
'{
"entity": "github-actions",
"source": "'${GITHUB_REPOSITORY}'",
"details": {
"github_repository": "$'{GITHUB_REPOSITORY}'",
"github_ref": "'${GITHUB_REF}'",
"github_workflow": "'${GITHUB_WORKFLOW}'",
"github_action": "'${GITHUB_ACTION}'",
"github_event_name": "'${GITHUB_EVENT_NAME}'",
"github_event_path": "'${GITHUB_EVENT_PATH}'",
"github_actor": "'${GITHUB_ACTOR}'",
"github_sha": "'${GITHUB_SHA}'"
},
"message": "Release failure on '${current_branch}'",
"alias": "release-failure-'${current_branch}'",
"description":"Release failure on '${current_branch}' see '${workflow_url}'",
"priority":"'${priority}'"
}'
else
curl -X POST "https://api.opsgenie.com/v2/alerts/${alias}/close?identifierType=alias" \
-H "Content-Type: application/json" \
-H "Authorization: GenieKey ${OPSGENIE_API_KEY}" \
-d '{}'
fi
The text was updated successfully, but these errors were encountered:
My team used this action as inspiration but added the ability to close an issue, I can open a PR with the following if yall would like.
The text was updated successfully, but these errors were encountered: