Skip to content

send a message to the specified Slack channel, and post a tweet on Twitter with the message and the link to the new idea. #39

@tres-caras

Description

@tres-caras

First, create a new file named merged_pr_notification.yml in the .github/workflows directory with the following content:

Copy code
name: Notify on PR Merged

on:
  pull_request:
    types:
      - closed

jobs:
  notify:
    if: github.event.pull_request.merged == true
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v2

      - name: Get new file URL
        run: bash ./.github/workflows/get-new-file-url.sh ${{ github.event.pull_request.head.sha }} ${{ secrets.GITHUB_TOKEN }}
        id: get-new-file-url

      - name: Send message to Slack
        uses: rtCamp/action-slack-notify@v2.1.2
        with:
          status: ${{ job.status }}
          fields: message,author
        env:
          SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
          SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
          SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
          SLACK_MESSAGE: A new idea was added to Ideario, check it out: ${{ steps.get-new-file-url.outputs.file_url }}
          MSG_MINIMAL: true

      - name: Post a tweet
        uses: ethomson/send-tweet-action@v1
        with:
          status: "A new idea was added to Ideario, check it out: ${{ steps.get-new-file-url.outputs.file_url }}"
          consumer_key: ${{ secrets.TWITTER_CONSUMER_KEY }}
          consumer_secret: ${{ secrets.TWITTER_CONSUMER_SECRET }}
          access_token: ${{ secrets.TWITTER_ACCESS_TOKEN }}
          access_token_secret: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}

Make sure to add the following secrets to your GitHub repository:

SLACK_WEBHOOK_URL: The webhook URL for your Slack workspace
SLACK_WEBHOOK: The Slack webhook secret
TWITTER_CONSUMER_KEY: Your Twitter app's consumer key
TWITTER_CONSUMER_SECRET: Your Twitter app's consumer secret
TWITTER_ACCESS_TOKEN: Your Twitter account's access token
TWITTER_ACCESS_TOKEN_SECRET: Your Twitter account's access token secret
This workflow will trigger when a pull request is merged into the main branch, send a message to the specified Slack channel, and post a tweet on Twitter with the message and the link to the new idea.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions