Skip to content

discord: Detect direct push by commit msg title#2

Merged
myme merged 2 commits intomainfrom
mmy/github-fix-discord-push-notification
Mar 7, 2025
Merged

discord: Detect direct push by commit msg title#2
myme merged 2 commits intomainfrom
mmy/github-fix-discord-push-notification

Conversation

@myme
Copy link
Contributor

@myme myme commented Mar 7, 2025

This skips pushes to branch which contain typical merge commit titles (ending in a (#123)). This simplifies clients slightly where they can just pass in the ${{ github.ref }}.

Example:

name: Discord Push Notification

on:
  push:
    branches:
      - main

jobs:
  notify_push:
    uses: novem-code/github-actions/.github/workflows/discord_push.yml@main
    with:
      branch_name: ${{ github.ref }}
      commit_message: ${{ github.event.head_commit.message }}
      commit_url: ${{ github.event.head_commit.url }}
      repo_full_name: ${{ github.repository }}
    secrets:
      discord_webhook: ${{ secrets.DISCORD_WEBHOOK_URL }}

This can be made into a workflow configuration later.

@myme myme force-pushed the mmy/github-fix-discord-push-notification branch 2 times, most recently from 9006d70 to dc082ec Compare March 7, 2025 13:13
This skips pushes to branch which contain typical merge commit
titles (ending in a `(#123)`).

This can be made into a workflow configuration later.
@myme myme force-pushed the mmy/github-fix-discord-push-notification branch from dc082ec to 5bc8f9c Compare March 7, 2025 13:15
Copy link
Contributor

@bjornars bjornars left a comment

Choose a reason for hiding this comment

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

ShipItGIF

notify_push:
uses: ./.github/workflows/discord_push.yml
if: github.ref == 'refs/heads/main' && github.event_name == 'push' && !startsWith(github.event.head_commit.message, 'Merge pull request')
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need this check here because the workflow is used for both push and pull_request triggers.

@myme myme merged commit d1af6ee into main Mar 7, 2025
@myme myme deleted the mmy/github-fix-discord-push-notification branch March 7, 2025 13:27
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.

2 participants