Skip to content

Custom action to send approval request to Slack

Notifications You must be signed in to change notification settings

TigerWest/slack-approval

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace
 
 

Repository files navigation

slack-approval

custom action to send approval request to Slack

trigger

  • When action is triggered, Post or Update in Slack, a reply message appears simultaneously with "Approve" and "Reject" buttons

approve

  • Clicking on "Approve" will execute next steps

reject and cancel

  • Clicking on "Reject" or "cancel workflow" will cause workflow to fail and update reply message

How To Use

  • First, create a Slack App and install in your workspace.
  • Second. set the App Manifest
{
    "display_information": {
        "name": "ApprveApp"
    },
    "features": {
        "bot_user": {
            "display_name": "ApproveApp",
            "always_online": false
        }
    },
    "oauth_config": {
        "scopes": {
            "bot": [
                "app_mentions:read",
                "channels:join",
                "chat:write",
                "users:read"
            ]
        }
    },
    "settings": {
        "interactivity": {
            "is_enabled": true
        },
        "org_deploy_enabled": false,
        "socket_mode_enabled": true,
        "token_rotation_enabled": false
    }
}
  • set workflow step
jobs:
  approval:
    runs-on: ubuntu-latest
    steps:
      - name: send approval
        uses: TigerWest/[email protected]
        env:
          SLACK_APP_TOKEN: ${{ secrets.SLACK_APP_TOKEN }}
          SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
          SLACK_SIGNING_SECRET: ${{ secrets.SLACK_SIGNING_SECRET }}
          SLACK_CHANNEL_ID: ${{ secrets.SLACK_CHANNEL_ID }}
        timeout-minutes: 10
        with:
            approvers: user1,user2
            minimumApprovalCount: 2
            baseMessagePayload: |
              {}
            successMessagePayload: |
              {}
            failMessagePayload: |
              {}

Set environment variables

  • SLACK_APP_TOKEN

    • App-level tokens on Basic Information page. (starting with xapp- )
  • SLACK_BOT_TOKEN

    • Bot-level tokens on OAuth & Permissions page. (starting with xoxb- )
  • SLACK_SIGNING_SECRET

    • Signing Secret on Basic Information page.
  • SLACK_CHANNEL_ID

    • Channel ID for which you want to send approval.

Set Inputs

  • baseMessageTs

    • If provided, updates the target message. If not provided, creates a new message
    • Optional
  • approvers

    • A comma-separated list of approvers' slack user ids
    • Required
  • minimumApprovalCount

    • The minimum number of approvals required
    • Optional (default: "1")
  • baseMessagePayload

    • The base message payload to display. If not set, will use default message from README. To customize, provide Slack message payload JSON
    • Optional (default: "{}")
  • successMessagePayload

    • The message body indicating approval is success. If not set, will use baseMessagePayload.
    • Optional (default: "{}")
  • failMessagePayload

    • The message body indicating approval is fail. If not set, will use baseMessagePayload.
    • Optional (default: "{}")

outputs

  • mainMessageTs

    • Timestamp of the main message sent to Slack
  • replyMessageTs

    • Timestamp of the reply message sent to Slack

About

Custom action to send approval request to Slack

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 100.0%