Skip to content

Integrating buttons with Github Actions #385

@vovados1

Description

@vovados1

Description

I’m trying to integrate buttons in Slack with GitHub Actions, so when I press a specific button, it runs a certain action. In the Slack documentation, it says there’s a url option where a request will be sent when the button is pressed. However, it requires running your own server to handle these requests. Is there any way to avoid running a server and still run the action I need? Here’s the payload I send:

- name: Send Slack notification for production approval
    uses: slackapi/slack-github-action@v2.0.0
    with:
      method: chat.postMessage
      token: ${{ secrets.SLACK_BOT_TOKEN }}
      payload: |
        channel: ${{ secrets.SLACK_CHANNEL_ID }}
        text: "New release request"
        blocks:
          - type: "header"
            text:
              type: "plain_text"
              text: "New release request"
          - type: "divider"
          - type: "section"
            fields:
              - type: "mrkdwn"
                text: "*Commit ID:*\n${{ github.event.pull_request.head.sha }}"
              - type: "mrkdwn"
                text: "*When:*\n${{ github.event.pull_request.merged_at }}"
              - type: "mrkdwn"
                text: "*Created by:*\n<${{ github.event.pull_request.user.html_url }}|@${{ github.event.pull_request.user.login }}>"
              - type: "mrkdwn"
                text: "*Merged by:*\n<${{ github.event.pull_request.merged_by.html_url }}|@${{ github.event.pull_request.merged_by.login }}>"
          - type: "divider"
          - type: "actions"
            elements:
              - type: "button"
                text:
                  type: "plain_text"
                  text: "Approve"
                action_id: "approve_production_deploy"
                value: "${{ github.event.pull_request.head.sha }}"
                url: // Here we need a forward url
                style: "primary"
                confirm:
                  title:
                    type: "plain_text"
                    text: "Are you sure?"
                  text:
                    type: "plain_text"
                    text: "Release the version to production? Action cannot be undone unless reverted manually"
                  confirm:
                    type: "plain_text"
                    text: "Release"
                  deny:
                    type: "plain_text"
                    text: "Close"
              - type: "button"
                text:
                  type: "plain_text"
                  text: "Reject"
                action_id: "reject_production_deploy"
                value: "${{ github.event.pull_request.head.sha }}"
                url: // Here we need a forward url
                style: "danger"
                confirm:
                  title:
                    type: "plain_text"
                    text: "Are you sure?"
                  text:
                    type: "plain_text"
                    text: "By rejecting this release preview is going to be returned to the latest release"
                  style: "danger"
                  confirm:
                    type: "plain_text"
                    text: "Reject"
                  deny:
                    type: "plain_text"
                    text: "Close"

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

Reproducible in:

package version:

node version:

OS version(s):

Steps to reproduce:

Expected result:

What you expected to happen

Actual result:

What actually happened

Attachments:

Logs, screenshots, screencast, sample project, funny gif, etc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions