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

[#1056] Added support for a webhook notification. #1273

Merged
merged 15 commits into from
Apr 29, 2024

Conversation

tannguyen04
Copy link
Contributor

@tannguyen04 tannguyen04 commented Apr 18, 2024

Checklist before requesting a review

closes #1056

  • I have formatted the subject to include ticket number as [#123] Verb in past tense with dot at the end.
  • I have added a link to the issue tracker
  • I have provided information in Changed section about WHY something was done if this was not a normal implementation
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • I have run new and existing relevant tests locally with my changes, and they passed
  • I have provided screenshots, where applicable

Changed

Screenshots

@github-actions github-actions bot temporarily deployed to commit April 18, 2024 15:34 Inactive
@AlexSkrypnyk AlexSkrypnyk changed the title [#1056] Add webhook notification [#1056] Added webhook notification Apr 18, 2024
@github-actions github-actions bot temporarily deployed to commit April 19, 2024 04:21 Inactive
Copy link

codecov bot commented Apr 19, 2024

Codecov Report

Attention: Patch coverage is 94.00000% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 60.09%. Comparing base (ddc20de) to head (02d02a1).

Files Patch % Lines
scripts/drevops/notify-webhook.sh 93.47% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1273      +/-   ##
===========================================
- Coverage    69.58%   60.09%   -9.50%     
===========================================
  Files           40       41       +1     
  Lines         2999     3047      +48     
===========================================
- Hits          2087     1831     -256     
- Misses         912     1216     +304     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@github-actions github-actions bot temporarily deployed to commit April 19, 2024 04:55 Inactive
@github-actions github-actions bot temporarily deployed to commit April 19, 2024 05:24 Inactive
@github-actions github-actions bot temporarily deployed to commit April 19, 2024 06:26 Inactive
@tannguyen04 tannguyen04 marked this pull request as ready for review April 19, 2024 07:39
@github-actions github-actions bot temporarily deployed to commit April 19, 2024 07:39 Inactive
Copy link
Member

@AlexSkrypnyk AlexSkrypnyk left a comment

Choose a reason for hiding this comment

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

@tannguyen04
Thank you for working on this.

We need to significantly simplify this to avoid using tokens and jq. The headers and body should also be simplified.

The value of DREVOPS_NOTIFY_WEBHOOK_PAYLOAD (used for body) should come from the outside of the script.
By default, we should be providing a JSON string with values similar to what is used in notify-email.sh - please see how that message is created.
The fields are: message(friendly message as in notify-email.sh), environment_url, project, ref, timestamp.

The core of this script should be a simple curl call:

if ! curl -L -s -o /dev/null -w '%{http_code}' \
  -X "${DREVOPS_NOTIFY_WEBHOOK_METHOD}" \
  -H "${DREVOPS_NOTIFY_WEBHOOK_HEADERS}" \
  -d "${DREVOPS_NOTIFY_WEBHOOK_PAYLOAD}" \
  "${DREVOPS_NOTIFY_WEBHOOK_URL}" | grep -q "${DREVOPS_NOTIFY_WEBHOOK_RESPONSE_STATUS}"; then
  fail "Unable to send notification to webhook ${DREVOPS_NOTIFY_WEBHOOK_URL}."
  exit 1
fi

.scaffold/tests/bats/notify.bats Outdated Show resolved Hide resolved
.scaffold/tests/bats/notify.bats Outdated Show resolved Hide resolved
.scaffold/tests/bats/notify.bats Outdated Show resolved Hide resolved
.scaffold/tests/bats/notify.bats Outdated Show resolved Hide resolved
.scaffold/tests/bats/notify.bats Show resolved Hide resolved
scripts/drevops/notify-webhook.sh Outdated Show resolved Hide resolved
@tannguyen04 tannguyen04 marked this pull request as draft April 25, 2024 03:42
@github-actions github-actions bot temporarily deployed to commit April 25, 2024 04:19 Inactive
@github-actions github-actions bot temporarily deployed to commit April 25, 2024 07:44 Inactive
@github-actions github-actions bot temporarily deployed to commit April 25, 2024 07:53 Inactive
@tannguyen04 tannguyen04 marked this pull request as ready for review April 25, 2024 08:08
@github-actions github-actions bot added PR: CONFLICT Pull request has a conflict that needs to be resolved before it can be merged and removed PR: CONFLICT Pull request has a conflict that needs to be resolved before it can be merged labels Apr 26, 2024
@AlexSkrypnyk AlexSkrypnyk enabled auto-merge (squash) April 26, 2024 19:05
@github-actions github-actions bot temporarily deployed to commit April 26, 2024 19:07 Inactive
@AlexSkrypnyk AlexSkrypnyk added this to the 1.20.1 milestone Apr 29, 2024
@AlexSkrypnyk AlexSkrypnyk changed the title [#1056] Added webhook notification [#1056] Added support for a webhook notification. Apr 29, 2024
@AlexSkrypnyk AlexSkrypnyk enabled auto-merge (squash) April 29, 2024 03:32
@github-actions github-actions bot temporarily deployed to commit April 29, 2024 03:39 Inactive
@AlexSkrypnyk AlexSkrypnyk merged commit fd6e8bf into develop Apr 29, 2024
19 of 20 checks passed
@AlexSkrypnyk AlexSkrypnyk deleted the feature/webhook-notification branch April 29, 2024 04:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Released in 1.21
Development

Successfully merging this pull request may close these issues.

Add webhook notification
2 participants