-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #119 from joshmfrankel/joshmfrankel/update-documen…
…tation-for-main-branch Added documentation section to explain running the workflow only on a specified branch
- Loading branch information
Showing
1 changed file
with
17 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,23 @@ steps: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required | ||
``` | ||
### Running a workflow only on the specified branch | ||
To run the notifier for a specific branch, you can utilize the either `github.ref_name` for pushes or `github.head_ref` for pull requests. For example, if you want to run the notifier only on the **origin/main** branch for pushes the following would constrain the workflow to that branch: | ||
|
||
```yaml | ||
steps: | ||
- name: Notify Slack Action | ||
uses: ravsamhq/[email protected] | ||
if: ${{ always() && github.ref_name == 'main' }} | ||
with: | ||
status: ${{ job.status }} | ||
notify_when: "failure" | ||
notification_title: "{workflow} is failing" | ||
env: | ||
SLACK_WEBHOOK_URL: ${{ secrets.ACTION_MONITORING_SLACK }} | ||
``` | ||
|
||
### Extended Example without User Mentions | ||
|
||
![](screenshots/without-mentions.png) | ||
|
@@ -43,7 +60,6 @@ steps: | |
notification_title: "{workflow} has {status_message}" | ||
message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}>" | ||
footer: "Linked Repo <{repo_url}|{repo}> | <{workflow_url}|View Workflow>" | ||
notify_when: "failure" | ||
env: | ||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | ||
``` | ||
|