Skip to content

Commit

Permalink
Merge pull request #47 from lifechurch/cv/add_teams
Browse files Browse the repository at this point in the history
add Teams deploy integrations
  • Loading branch information
chrisvaughn authored Mar 27, 2020
2 parents b4acd85 + 0d9c2cb commit 8a59485
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ env:

# Deploy Events

Currently NewRelic, Slack, and Datadog deploy events are supported.
Currently NewRelic, Slack, Datadog, & Microsoft Teams deploy events are supported.

In Gitlab for NewRelic, you'll need to add a secret variable with the NewRelic API key and App Ids
for each stage you want a deployment event for. Like:
Expand Down Expand Up @@ -301,6 +301,25 @@ DATADOG_TAGS="deploys:api","foo:bar"
DATADOG_TEXT=\n%%%\n### Success\n%%%
```

For Teams, you can simply set a Gitlab secret variable with a [Teams Incoming Webhook](https://docs.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook#add-an-incoming-webhook-to-a-teams-channel) if you want notifications for every stage.

```
TEAMS_WEBHOOK=xxx
```

If you want notifications for specific stages use the following format.

```
TEAMS_{{STAGE}}_WEBHOOK=xxx
```

E.g.

```
TEAMS_STAGING_WEBHOOK=xxx
TEAMS_PRODUCTION_WEBHOOK=xxx
```

# Manifest-less Deploys
Starting in 3.1.0, we added an option for manifest-less deploys to help us migrate away from Deis Workflow. In order for this to work, we had to make some very opinionated decisions regarding our manifests. These may not work for your organization. If this is the case, we encourage you to fork our project and make your own default manifests. They can be found in the manifests directory.

Expand Down
10 changes: 10 additions & 0 deletions deploy
Original file line number Diff line number Diff line change
Expand Up @@ -235,5 +235,15 @@ if [ "$DATADOG_API_KEY" ]; then
}" "$URL" > /dev/null || true
fi

if [ "$TEAMS_WEBHOOK_URL" ]; then
echo "Sending deploy event to Teams channel..."
curl --silent -X POST -H 'Content-type: application/json' \
-d \
"{
\"text\": \"Kubernetes Deployment to $KUBE_NAMESPACE by $GITLAB_USER_LOGIN\n\n
Successfully deployed to $REAL_JOB_STAGE\",
}" $TEAMS_WEBHOOK_URL > /dev/null || true
fi

echo "Application is accessible at: ${CI_ENVIRONMENT_URL}"
echo ""
11 changes: 11 additions & 0 deletions src/common.bash
Original file line number Diff line number Diff line change
Expand Up @@ -318,4 +318,15 @@ get_deploy_events() {
fi
done
fi

if env | grep -i -e '^TEAMS' > /dev/null; then
TEAMS=$(env | grep -i -e '^TEAMS')
for i in $TEAMS; do
if echo "$i" | grep -i -e "$CI_JOB_STAGE" | grep -i -e "WEBHOOK" > /dev/null; then
export TEAMS_WEBHOOK_URL=$(echo $i | cut -d'=' -f2)
elif echo "$i" | grep -i -e "^TEAMS_WEBHOOK" > /dev/null; then
export TEAMS_WEBHOOK_URL=$(echo $i | cut -d'=' -f2)
fi
done
fi
}

0 comments on commit 8a59485

Please sign in to comment.