Send slack notification #24
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Send slack notification | |
on: | |
workflow_run: | |
workflows: [compile, conventions] | |
types: | |
- completed | |
jobs: | |
notify: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: 'Download artifact' | |
uses: actions/github-script@v5 | |
with: | |
script: | | |
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
run_id: context.payload.workflow_run.id, | |
}); | |
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => { | |
return artifact.name == "notification" | |
})[0]; | |
let download = await github.rest.actions.downloadArtifact({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
artifact_id: matchArtifact.id, | |
archive_format: 'zip', | |
}); | |
let fs = require('fs'); | |
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/notification.zip`, Buffer.from(download.data)); | |
- name: 'Unzip artifact' | |
run: | | |
pwd | |
unzip notification.zip | |
- name: 'Send notification' | |
run: | | |
pwd | |
./scripts/githubActions/sendSlackNotification.sh | |
env: | |
MESSAGEPATH: ./notificationMessage.txt | |
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }} | |
CHANNEL: pull-requests | |