Skip to content

Commit

Permalink
Merge pull request #6 from industrydive/QA-walkthrough-changes
Browse files Browse the repository at this point in the history
Qa walkthrough changes
  • Loading branch information
sw3dish authored Dec 5, 2019
2 parents 0f0b6fb + 6420582 commit d77060f
Show file tree
Hide file tree
Showing 8 changed files with 1,892 additions and 50 deletions.
17 changes: 17 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = {
"env": {
"browser": true,
"commonjs": true,
"es6": true
},
"extends": "airbnb-base",
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parserOptions": {
"ecmaVersion": 2018
},
"rules": {
}
};
11 changes: 5 additions & 6 deletions .gcloudignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@
# below:
.git
.gitignore
.idea
.env.yaml
.eslintrc.js
node_modules
#!include:.gitignore

package-lock.json
README.md
CONTRIBUTING.md
.eslintrc.js
example.env.yaml
demo_images
README.md
LICENSE
CONTRIBUTING.md
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Environment Variables
.env.yaml

# Dependency related
node_modules
.idea
10 changes: 1 addition & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Contributing

When contributing to this repository, please first discuss the change you wish to make via issue,
email, or any other method with the owners of this repository before making a change.
When contributing to this repository, please first discuss the change you wish to make via issue with the owners of this repository before making a change.

Please note we have a code of conduct, please follow it in all your interactions with the project.

Expand Down Expand Up @@ -71,13 +70,6 @@ further defined and clarified by project maintainers.

### Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at [INSERT EMAIL ADDRESS]. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
Expand Down
68 changes: 35 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ We wanted to create a Slack bot that could easily facilitate incident response h

2. Submitting the incident form results in the following channel being created with your members, communications, and commander. The briefing message is sent in the new channel as seen below:

<img src="https://github.com/industrydive/incident_response/blob/master/demo_images/channel_image.png" alt="channel alert" width="150px" height="75px">
<img src="https://github.com/industrydive/incident_response/blob/master/demo_images/channel_image.png" alt="channel alert" width="250px" height="75px">

<img src="https://github.com/industrydive/incident_response/blob/master/demo_images/channel_message.png" alt="channel message" width="600px" height="300px">

Expand All @@ -34,56 +34,58 @@ Below is a step by step series of examples that tell you how to get a developmen

2. You must clone this repo.

3. Make sure that you are on the correct Google Cloud project using:

```
gcloud config list
```

Then deploy each of the Cloud Functions to your Google Cloud project. See the `Deploying the Cloud Functions` section below. NOTE: When you deploy the function, the success output includes the HTTP trigger endpoint as `httpsTrigger`. Make sure to save this somewhere as you will need them in the next step. You can also find this info in the Google Cloud Console later on if you need.

4. Create your Slack app:
* Navigate to https://api.slack.com/apps and hit the create new app button
* In your new app, navigate to `Slash Commands` and create a new Slash Command. You may call this whatever you like, and input the HTTP trigger endpoint for the `incidentSlashCommand` function in the Request URL section.
* In your new app, navigate to and enable `Interactive Components`. In the Request URL section here you must enter the HTTP trigger endpoint for the `handleIncidentForm` function.
3. Create your Slack app:
* Navigate to https://api.slack.com/apps and create your new Slack app.
* In your new app, navigate to `Slash Commands` and create a new Slash Command. You may call this whatever you like. Place `https://placeholder.com` in the Request URL section for now. Remember where this is because you will have to replace this with the HTTP trigger endpoint for the `incidentSlashCommand` function once you have completed step 4.
* In your new app, navigate to and enable `Interactive Components`. Place `https://placeholder.com` in the Request URL section for now. Remember where this is because you will have to replace this with the HTTP trigger endpoint for the `handleIncidentForm` function once you have completed step 4.
* In your new app, navigate to `Bots` and add a new bot user. You may call it whatever you would like.
* Navigate to `OAuth & Permission -> Scopes` and add the `channels:write` and the `chat:write:bot` permissions.
* Now you can navigate to `OAuth & Permissions` and hit the `Install to Workspace` button.

5. You must set and deploy your environment variables. Rename `example.env.yaml` to `.env.yaml` and input your environment variables.
4. You must set your environment variables and deploy your Cloud Functions.
* Rename `example.env.yaml` to `.env.yaml` and input your environment variables.

NOTE: For us, the three users that are always added to the incident channel upon creation are the members of our product
team. You can follow this [link](https://help.workast.com/hc/en-us/articles/360027461274-How-to-find-a-Slack-user-ID) to
easily find the user IDs for the members of your team that you would like to include.
NOTE: For us, the three users that are always added to the incident channel upon creation are the members of our product
team. You can follow this [link](https://help.workast.com/hc/en-us/articles/360027461274-How-to-find-a-Slack-user-ID) to
easily find the user IDs for the members of your team that you would like to include.

For instructions on how to deploy these environment variables, see the `Deploying environment variables` section below.
* Now you can deploy each of your cloud functions by following the instructions in the [deployment section](#deploying-the-cloud-functions)

NOTE: You may want to save the HTTP trigger endpoint that is part of the output from the deployment command for use in step 5, although you can find this information for each cloud function in the Google Cloud Console later.

5. Now that you have deployed your Cloud Functions, go back and replace the placeholder URLs with the correct Cloud Function HTTP trigger endpoints. If you can't remember where these were/which endpoint belongs where, then reference step 3.

## Deployment

### Deploying the Cloud Functions
Before deploying your Cloud Functions, make sure that you have created a file called `.gcloudignore` containing all of the files you would like to keep from getting uploaded to Google Cloud. See [documentation](https://cloud.google.com/sdk/gcloud/reference/topic/gcloudignore) on how to create this file.
6. In Slack, navigate to OAuth & Permissions and hit the Install to Workspace button. Your Slack app should now function as seen in the [demo](#basic-app-flow)

To deploy the Cloud Function you will type the following command from the main directory of the project.

`gcloud functions deploy FUNCTION_NAME --runtime nodejs10 --trigger-http`
## Deployment

The deploy should fail if there are any errors.
### Deploying the Cloud Functions
Before deploying, make sure of the following:
* All files that you don't want to add to Google Cloud have been added to .gcloudignore
* You have the correct project selected.
* You can check the above with this command:

### Deploying environment variables
To deploy the environment variables for the Cloud Functions you will run the following command after adding your new environment variables to env file.
```
gcloud config list
```
If you are on the wrong project then you can use the following commands to find and switch projects.

`gcloud functions deploy FUNCTION_NAME --env-vars-file .env.yaml`
```
gcloud projects list (to get the desired project ID)
```
```
gcloud config set project <project-ID>
```

Go to the Google Cloud Console and find the function that you were working with. Check that the environment variables are present.
To deploy the Cloud Functions and environment variables you will type and execute the following commands from the main directory of the project.

If you would like to deploy just a single environment variable, you can also successfully do that with the following command.
`gcloud functions deploy incidentSlashCommand --runtime nodejs10 --trigger-http --env-vars-file .env.yaml`

`gcloud functions deploy FUNCTION_NAME --set-env-vars FOO=bar`
`gcloud functions deploy handleIncidentForm --runtime nodejs10 --trigger-http --env-vars-file .env.yaml`

Check to see that the environment variable is present. You can do this by viewing your function in the Google Cloud Console.
The deploy should fail if there are any errors.

You can check that the functions have the correct source code/environment variables by visiting them in the console. The only files that are required by the functions are incidentSlackBot.js and package.json.

## Built With

Expand Down
2 changes: 1 addition & 1 deletion example.env.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
SLACK_TOKEN: This can be found under Basic Information -> App Credentials -> Verification Token in your app
INCIDENT_BOT_TOKEN: This can be found under OAuth & Permissions -> Bot User OAuth Access Token and begins with 'xobp'
USER_SLACK_TOKEN: This can be found under OAuth & Permissions -> OAuth Access Token and begins with 'xoxp'
JIRA_DOC: This is a link to additional guidelines for how to handle the incident. Will be included in channel description.
INCIDENT_DOC_URL: This is a link to additional guidelines for how to handle the incident. Will be included in channel description.
USER_ID_1: User ID of first person that will be added to incident channel
USER_ID_2: User ID of second person that will be added to incident channel
USER_ID_3: User ID of third person that will be added to incident channel
2 changes: 1 addition & 1 deletion incidentSlackBot.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ function setChannelTopic(channelID, commander, comms) {
if (comms) {
topic += ` Comms: <@${comms}>`;
}
topic += ` Jira Doc: ${process.env.JIRA_DOC}`;
topic += ` Incident Doc: ${process.env.INCIDENT_DOC_URL}`;
const channelTopicBody = {
token: process.env.USER_SLACK_TOKEN,
channel: channelID,
Expand Down
Loading

0 comments on commit d77060f

Please sign in to comment.