I'm trying to send customized slack notifications about the status of github action workflows. I've built my custom messages with the help of https://github.com/8398a7/action-slack integration. However, I'm trying to send the github action artifact that is generated with each workflow to my slack channel. Is that something that can be done?
Below is the yaml file that I'm using:
...
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
smoke-test:
runs-on: ubuntu-latest
container:
image: dannydainton/htmlextra
steps:
- name: Cloning Repository
id: initializing
uses: actions/checkout@master
- name: Executing API test suite
run: newman run "postman_collection.json" --environment "postman_environment.json" --reporters cli,htmlextra --reporter-htmlextra-export report.html
- if: failure()
uses: actions/upload-artifact@v2
id: generating-report
with:
name: reports
path: report.html
- uses: 8398a7/action-slack@v3
with:
status: custom
custom_payload: |
{
text: "Test Execution Passed",
attachments: [{
color: 'good',
text: `Test Execution for ${process.env.AS_WORKFLOW} workflow has SUCCEEDED! :heavy_check_mark:`,
fields: [{
title: "Test Type",
value: 'Smoke Test',
short: false
},
{
title: "Overall APIs Status",
value: "Healthy :heavy_check_mark:",
short: false
},
{
title: "Repository",
value: `${process.env.AS_REPO}`,
short: false
},
{
title: "Author",
value: `${process.env.AS_AUTHOR}`,
short: false
},
{
title: "Execution Time",
value: `${process.env.AS_TOOK}`,
short: false
},
{
title: "Number of Requests",
value: '39',
short: true
},
{
title: "Number of Assertions",
value: '64',
short: true
}]
}]
}
if: success()
- uses: 8398a7/action-slack@v3
if: failure()
with:
status: custom
custom_payload: |
{
text: 'Test Execution Failed :siren_alert::siren_alert:',
attachments: [{
color: 'danger',
text: `Test Execution for ${process.env.AS_WORKFLOW} workflow has FAILED! :x:`,
fields: [{
title: "Test Type",
value: 'Smoke Test',
short: true
},
{
title: "Repository",
value: `${process.env.AS_REPO}`,
short: true
},
{
title: "Author",
value: `${process.env.AS_AUTHOR}`,
short: false
}],
actions: [{
name: "report",
text: "View Report",
type: "button",
value: `https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}`
}]
}]
}
So I need to pass the artifact to the step which sends a slack notification on failure.
Thanks