Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allows to use a custom environment variable for Slack webhook #36

Merged
merged 1 commit into from
Mar 23, 2020

Conversation

KillianHmyd
Copy link
Contributor

This is particularly useful when using CircleCI and their context system.
In our organisation, the context has a default SLACK_WEBHOOK value but we need to override it for some repositories (but still use the context).

Since in CircleCI the context override custom environment variables we need this parameter to use another variable.

@BeyondEvil
Copy link
Contributor

Only thing I'm missing are some tests. 😊

@@ -16,7 +16,8 @@ module.exports = async (pluginConfig, context) => {
env: { SEMANTIC_RELEASE_PACKAGE, npm_package_name }
} = context
const {
slackWebhook = process.env.SLACK_WEBHOOK,
slackWebhookEnVar = 'SLACK_WEBHOOK',
Copy link
Contributor

@BeyondEvil BeyondEvil Mar 19, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this variable used again in this file? Apart from row 20 obviously. 😊 Or maybe this is need for the const magic with defaults to work? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, it is only used at line 20. It is needed for the default slackWebhook value 👌.
I can create the slackWebhook constant outside the destructuring assignement if you think it is clearer

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks nice 😊

README.md Outdated
| `onFailTemplate` | Provides a template for the slack message object on fail when `notifyOnFail` is `true`. See [templating](#templating). | undefined |
| `markdownReleaseNotes` | Pass release notes through markdown to slack formatter before rendering. | false |
| `slackWebhook` | Slack webhook created when adding app to workspace. | SLACK_WEBHOOK |
| `slackWebhookEnVar` | Environment variable to use to select the default Slack webhook value. | SLACK_WEBHOOK |
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to clarify so that I understand it correctly. The default value of slackWebhook is the value of SLACK_WEBHOOK, and for slackWebhookEnVar it is actually the string 'SLACK_WEBHOOK'?

If so, do you think there is a good way to be more clear about this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is exactly it. I tried to improve the documentation, is it clearer ?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it was much clearer after your update. I did, however, have some difficulties with understanding the description for slackWebhookEnVar. You can see the comment further down 🙂

@KillianHmyd
Copy link
Contributor Author

@BeyondEvil I wasn't sure where you wanted me to add the tests, so I've tested verifyCondition

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@juliuscc
Copy link
Owner

juliuscc commented Mar 21, 2020

For this PR to be merged I:

  • am waiting for @BeyondEvil about the tests
  • would like the description of slackWebhookEnVar to be clarified

@BeyondEvil
Copy link
Contributor

This is particularly useful when using CircleCI and their `context` system.
In our organisation, the context has a default SLACK_WEBHOOK value but we need to override it for some repositories (but still use the context).

Since in CircleCI the context override custom environment variables we need this parameter to use another variable.
@KillianHmyd
Copy link
Contributor Author

@juliuscc Sorry forgot to push the README modification. I changed the description of slackWebhookEnVar with the the description you suggested 👍

@juliuscc
Copy link
Owner

Great! LGTM!

Thanks for the feature @KillianHmyd and thanks for the help reviewing the PR @BeyondEvil

@juliuscc juliuscc merged commit d67ad65 into juliuscc:master Mar 23, 2020
juliuscc pushed a commit that referenced this pull request Mar 23, 2020
This is particularly useful when using CircleCI and their `context` system.
In our organisation, the context has a default SLACK_WEBHOOK value but we need to override it for some repositories (but still use the context).

Since in CircleCI the context override custom environment variables we need this parameter to use another variable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants