mirror of
https://github.com/clockworklabs/SpacetimeDB.git
synced 2026-05-22 23:51:30 -04:00
3fcb5056b2
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
46 lines
1.7 KiB
YAML
46 lines
1.7 KiB
YAML
name: Discord notifications
|
|
|
|
on:
|
|
pull_request:
|
|
types: [closed]
|
|
|
|
jobs:
|
|
discordNotification:
|
|
runs-on: ubuntu-latest
|
|
if: github.event.pull_request.merged == true &&
|
|
github.event.pull_request.base.ref == 'master'
|
|
env:
|
|
CHECK_NAME: Internal Tests
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
steps:
|
|
- name: Set up GitHub CLI
|
|
run: |
|
|
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo tee /usr/share/keyrings/githubcli-archive-keyring.gpg > /dev/null
|
|
sudo apt-get install -y apt-transport-https
|
|
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list
|
|
sudo apt-get update
|
|
sudo apt-get install gh
|
|
|
|
- name: Fetch Check Run Results
|
|
run: |
|
|
RESULT="$(gh pr checks "${{github.event.pull_request.html_url}}" --json 'name,state' |
|
|
jq -r ".[] | select(.name==\"${CHECK_NAME}\").state")"
|
|
|
|
if [ -z "$RESULT" ]; then
|
|
RESULT="The check did not run!"
|
|
fi
|
|
|
|
echo "CHECK_RESULT=${RESULT}" >> $GITHUB_ENV
|
|
|
|
- name: Send Discord notification
|
|
env:
|
|
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
|
|
PR_TITLE: ${{ github.event.pull_request.title }}
|
|
PR_NUMBER: ${{ github.event.pull_request.number }}
|
|
PR_URL: ${{ github.event.pull_request.html_url }}
|
|
CHECK_RESULT: ${{ env.CHECK_RESULT }}
|
|
run: |
|
|
curl -X POST -H 'Content-Type: application/json' -d '{
|
|
"content": "'"PR merged: [(#${PR_NUMBER}) ${PR_TITLE}](${PR_URL})\\n${CHECK_NAME} result: ${CHECK_RESULT}"'"
|
|
}' ${DISCORD_WEBHOOK_URL}
|