Slack
Slack is a communication tool based on text chat. All stakeholders follow some channels and discuss in threads inside the channels. It’s convenient to send monitoring alerts to the channel as it has great visibility, it is received immediately and users can configure their own notifications.
Get a Slack account
If you don’t already have a Slack account, follow the process:
- Access the DfE Slack
- Click “Create an account”
- Enter your email address
- Confirm your email address and follow the instructions
Create a Slack app
- Navigate to Your apps
- Click “Create New App”
- Select “From scratch”
- App name:
<Name of the service> <optional identifier>
- Worskspace: “Department for Education”
- Click “Create app”
- Click “Collaborators”
- Add digital tools support engineers (ask in Digital tools support)
- Add other team members and managers
Request incoming webhook
- Navigate to the app using the link generate above or access it via Your apps
- Click “Incoming Webhooks”
- On “Activate Incoming Webhooks”, switch to “On”
- Click “Request To Add New Webhook”
- Fill in business justification
- Wait for Digital tools support to approve the request
Create new webhooks
Onve authorised, it is possible to create multiple webhooks for the same app, and point them to different channels.
- Click “Add New Webhook to Workspace”
- Select the channel
- The webhook is created and you can copy the unique link
Use the webhook
Local test
Test manually using the curl
command shown on the “Incoming webhooks” page
Gihub actions
- Ideally store the webhook as a secret in keyvault.
- Retrieve the secret with the az cli action
- uses: Azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Retrieve Slack Webhook from key vault
uses: azure/CLI@v1
id: fetch-slack-webhook
with:
inlineScript: |
SECRET_VALUE=$(az keyvault secret show --name "SLACK-WEBHOOK" --vault-name "${{ secrets.INFRA_KEY_VAULT}}" --query "value" -o tsv)
echo "::add-mask::$SECRET_VALUE"
echo "SLACK-WEBHOOK=$SECRET_VALUE" >> $GITHUB_OUTPUT
- Use a Github actions like action-slack-notify to post the message to the channel. Example:
- name: Slack Notification
if: failure()
uses: rtCamp/action-slack-notify@master
env:
SLACK_COLOR: '#ff0000'
SLACK_TITLE: Failure to Build API
SLACK_MESSAGE: The pipeline has failed to build the API image
SLACK_WEBHOOK: "${{ steps.fetch-slack-webhook.outputs.SLACK-WEBHOOK }}"
Recover app
If all the app collaborators have left, the webhooks cannot be updated. It is required to recover the app to add a collaborator.
- Find an existing Slack notification from this app in the channel
- Hover and select “Configuration”. This takes you to the workspace configuration for this app. Take not of the URL
- Go to the #requests-slack channel
- Choose the “General Slack query” workflow
- Request to be added as a collaborator on the app, using the above URL. If digital tool support are not already collaborators, they may have to create a ticket with Slack support.