Consolidate Discord notification steps #4088
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
After #4082, I wanted to look for ways to set the first parameter of the Discord notification script (
success
orfailure
) without environment variables, extra pseudo-steps ("Set Success"), or side effects. Gradually I realized that writing agit clone
command in every place we want to notify was a bit duplicative and could use better encapsulation.Changes
notify.yml
action wrapper provides the nice API thatDiscordHooks/github-actions-discord-webhook
should have.name
andsuccess
are accepted, and theDISCORD_WEBHOOK
secret is required.git clone
logic required to use it is now centralized in one place. If the optimal notification method changes in the future, we will be able to update it in just one spot.success
andfailure
based on the value of the booleansuccess
input, with no environment variable twiddling involved.notify.yml
, and thecontains
expression usees the!
not operator instead of== false
.notify
jobs intest.yml
andsmoke.yml
now depend on their respectivebuild-*
steps to ensure that failure can be detected by checkingcontains(needs.*.result, 'failure')
(if you onlyneeds
the intermediate step, its status will beskipped
when a previous step fails).This should be a bit more maintainable, and it gave me some more practice in action coding.