Skip to content

Slack notification when nightly build fail #5280

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 22, 2025
Merged
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/pypi-nightly-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,42 @@ jobs:
with:
password: ${{ secrets.PYPI_API_TOKEN }}
skip-existing: true

notify-slack-failure:
runs-on: ubuntu-latest
needs: [check-date, nightly-build-pypi, extract-build-number, wait-for-buildkite, publish-to-pypi]
if: failure() # Only run this job if any of the previous jobs failed
steps:
- name: Prepare failure message
id: message_content
run: |
TITLE_TEXT="Workflow ${{ github.workflow }} failed."
if [[ "${{ needs.wait-for-buildkite.result }}" == "failure" ]]; then
MARKDOWN_TEXT="🚨 Workflow <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|*${{ github.workflow }}*> failed at Buildkite step. <https://buildkite.com/skypilot-1/smoke-tests/builds/${{ needs.extract-build-number.outputs.build_number }}|Buildkite Log>"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also add the commit for the nightly build in the message as well?

echo "message_text=${TITLE_TEXT}" >> $GITHUB_OUTPUT
echo "message_block=${MARKDOWN_TEXT}" >> $GITHUB_OUTPUT
else
MARKDOWN_TEXT="🚨 Workflow <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|*${{ github.workflow }}*> failed."
echo "message_text=${TITLE_TEXT}" >> $GITHUB_OUTPUT
echo "message_block=${MARKDOWN_TEXT}" >> $GITHUB_OUTPUT
fi

- name: Notify Slack channel on failure
uses: slackapi/[email protected]
with:
method: chat.postMessage
token: ${{ secrets.SLACK_BOT_TOKEN }}
payload: |
{
"channel": "${{ secrets.SLACK_CHANNEL_ID }}",
"text": "${{ steps.message_content.outputs.message_text }}",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "${{ steps.message_content.outputs.message_block }}"
}
}
]
}