Status embed #585
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
# Sends a status embed to a discord webhook | |
name: Status embed | |
on: | |
workflow_run: | |
workflows: | |
- CI | |
types: | |
- completed | |
jobs: | |
status_embed: | |
name: Send status embed to Discord | |
runs-on: ubuntu-latest | |
steps: | |
# A workflow_run event does not contain all the information | |
# we need for a PR embed. That's why we upload an artifact | |
# with that information in the Lint workflow. | |
- name: Get pull request information | |
id: pr_info | |
if: github.event.workflow_run.event == 'pull_request' | |
run: | | |
curl -s -H "Authorization: token $GITHUB_TOKEN" ${{ github.event.workflow_run.artifacts_url }} > artifacts.json | |
DOWNLOAD_URL=$(cat artifacts.json | jq -r '.artifacts[] | select(.name == "pull-request-payload") | .archive_download_url') | |
[ -z "$DOWNLOAD_URL" ] && exit 1 | |
curl -sSL -H "Authorization: token $GITHUB_TOKEN" -o pull_request_payload.zip $DOWNLOAD_URL || exit 2 | |
unzip -p pull_request_payload.zip > pull_request_payload.json | |
[ -s pull_request_payload.json ] || exit 3 | |
echo "::set-output name=pr_author_login::$(jq -r '.user.login // empty' pull_request_payload.json)" | |
echo "::set-output name=pr_number::$(jq -r '.number // empty' pull_request_payload.json)" | |
echo "::set-output name=pr_title::$(jq -r '.title // empty' pull_request_payload.json)" | |
echo "::set-output name=pr_source::$(jq -r '.head.label // empty' pull_request_payload.json)" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# Send an informational status embed to Discord instead of the | |
# standard embeds that Discord sends. This embed will contain | |
# more information and we can fine tune when we actually want | |
# to send an embed. | |
- name: Github actions status embed for Discord | |
uses: SebastiaanZ/github-status-embed-for-discord@v0.3.0 | |
with: | |
# Our Github actions webhook | |
webhook_id: '784184528997842985' | |
webhook_token: ${{ secrets.GHA_WEBHOOK_TOKEN }} | |
# Workflow information | |
status: ${{ github.event.workflow_run.conclusion }} | |
pr_author_login: ${{ steps.pr_info.outputs.pr_author_login }} | |
pr_number: ${{ steps.pr_info.outputs.pr_number }} | |
pr_title: ${{ steps.pr_info.outputs.pr_title }} | |
pr_source: ${{ steps.pr_info.outputs.pr_source }} |