Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/onsails/cloudbuild-slack
Google Cloud Build notifications in Slack using Cloud Function
https://github.com/onsails/cloudbuild-slack
google-cloud-build google-cloud-platform google-pubsub slack slack-webhook
Last synced: about 2 months ago
JSON representation
Google Cloud Build notifications in Slack using Cloud Function
- Host: GitHub
- URL: https://github.com/onsails/cloudbuild-slack
- Owner: onsails
- License: mit
- Created: 2020-04-27T20:04:52.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-10-31T23:36:26.000Z (about 2 months ago)
- Last Synced: 2024-11-01T00:24:42.358Z (about 2 months ago)
- Topics: google-cloud-build, google-cloud-platform, google-pubsub, slack, slack-webhook
- Language: TypeScript
- Homepage:
- Size: 446 KB
- Stars: 12
- Watchers: 2
- Forks: 3
- Open Issues: 30
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Google Cloud Function sending Cloud Build statuses to a Slack channel, written in TypeScript
Features:
- [x] send slack notifications about successful and failed builds;
- [x] link to build details in slack message;
- [x] no need in additional step in cloudbuild.yaml;
- [x] report success and failure statuses;
- [ ] show trigger information in slack message;
- [x] customize slack message using substitution in cloudbuild.yaml.![Slack message](https://github.com/onsails/cloudbuild-slack/raw/master/screenshot.png "Slack message")
![Slack message](https://github.com/onsails/cloudbuild-slack/raw/master/screenshot-fail.png "Slack message")# Deploy
Prerequisites:
* Google Cloud Platform project with enabled Cloud Functions API;
* gcloud command-line util authorized to deploy cloud functions;
* Slack webhook url.Deployment:
```bash
SLACK_WEBHOOK_URL=https://hooks.slack.com/services/YOUR_TOKENS ./deploy.sh
```This script will deploy cloud function `gcbSubscribeSlack` triggered by `cloud-build` PubSub topic.
Message content can be (optionally) defined by `_SLACK_MESSAGE_TEMPLATE` substitution in cloudbuild.yaml. Value should be a valid [ejs](https://ejs.co) template:
```yaml
steps:# ... build steps ...
substitutions:
_SLACK_MESSAGE_TEMPLATE: '<%= emoji %> *https://<%= build.substitutions._OVERLAY %>.example.com* frontend build & deploy `<%= build.id %>` <%= build.status %>'
````emoji` corresponds to a build status, `build` is object containing build information, it's structure is defined [here](https://github.com/onsails/cloudbuild-slack/blob/master/src/pubsub.ts).
The default message template is ```<%= emoji %> `<%= build.id %>` <%= build.status %>```