custom action to send approval request to Slack
- When action is triggered, Post or Update in Slack, a reply message appears simultaneously with "Approve" and "Reject" buttons
- Clicking on "Approve" will execute next steps
- Clicking on "Reject" or "cancel workflow" will cause workflow to fail and update reply message
- 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: |
{}
-
SLACK_APP_TOKEN
- App-level tokens on
Basic Information page
. (starting withxapp-
)
- App-level tokens on
-
SLACK_BOT_TOKEN
- Bot-level tokens on
OAuth & Permissions page
. (starting withxoxb-
)
- Bot-level tokens on
-
SLACK_SIGNING_SECRET
- Signing Secret on
Basic Information page
.
- Signing Secret on
-
SLACK_CHANNEL_ID
- Channel ID for which you want to send approval.
-
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: "{}")
-
mainMessageTs
- Timestamp of the main message sent to Slack
-
replyMessageTs
- Timestamp of the reply message sent to Slack