This is about sending notifications to Slack Channel via using Github Actions pipeline.
Link to Github Market Place -> Github Action
Usage
- In the below stated example, separate job for Notifications has been created which will send the notification to the SLACK CHANNEL irrespective of the build job status.
- Message to be sent can be customised as per the need, you can include other properties as well using Github Contexts.
- In order to use this, all you need is to create a Web-hook in your Slack Channel, follow this link for info about creating a one.
- Once you have created the web-hook, just add the Web-hook Address in secrets and utilise in your Action File in this manner
${{ secrets.SECRET_NAME }}
.
Usage
- In the below stated example, separate job for
Notifications
has been created which will send the notification to the SLACK CHANNEL irrespective of the build job status. - Message to be sent can be customised as per the need, you can include other properties as well using Github Contexts.
- In order to use this, all you need is to create a Web-hook in your Slack Channel, follow this link for info about creating a one.
- Once you have created the web-hook, just add the Web-hook Address in secrets and utilise in your Action File in this manner
${{ secrets.SECRET_NAME }}
. Sample Usage
name: Pipeline Name on: push: branches: [ branch_name ] pull_request: branches: [ branch_name ] jobs: build: runs-on: ubuntu-latest steps: - name: Demo Step run: docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:$GITHUB_RUN_NUMBER notify: runs-on: ubuntu-latest if: always() needs: build steps: - name: Send a Notification id: notify uses: thechetantalwar/slack-notify@v2 with: slack_webhook_url: ${{ secrets.SLACK_HOOK }} message: "Github Action Build Number ${{ github.run_number }} Completed for ${{ github.repository }} and the outcome is ${{ needs.build.result }}."
The above stated sample will send a message like below