Skip to content

Commit e0f4df6

Browse files
committed
ci: ping Slack on deploys
Mirrors the deploy notifications in codeplain-api: post to the SLACK_WEBHOOK_URL on deploy start, success and failure so releases are visible without watching the Actions tab. Covers both deploy paths in this repo: - PyPI release publish (start / build failure / publish success / failure) - install script upload to R2 (success / failure) Each ping is guarded on the webhook being configured, so forks and repos without the secret are unaffected.
1 parent ba6cda7 commit e0f4df6

2 files changed

Lines changed: 51 additions & 0 deletions

File tree

.github/workflows/publish-install-script.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ jobs:
1414
name: Upload to Cloudflare R2
1515
runs-on: ubuntu-latest
1616

17+
env:
18+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
19+
1720
steps:
1821
- uses: actions/checkout@v4
1922

@@ -54,3 +57,17 @@ jobs:
5457
--content-type "text/plain"
5558
echo "✓ examples.ps1 uploaded to R2"
5659
60+
- name: Notify Slack (success)
61+
if: ${{ success() && env.SLACK_WEBHOOK_URL != '' }}
62+
run: |
63+
curl -s -X POST "$SLACK_WEBHOOK_URL" \
64+
-H 'Content-type: application/json' \
65+
--data "{\"text\":\"*Codeplain Client*: Install scripts deployed to R2 :white_check_mark: (\`${GITHUB_SHA:0:7}\`, by *${{ github.actor }}*).\"}"
66+
67+
- name: Notify Slack (failure)
68+
if: ${{ failure() && env.SLACK_WEBHOOK_URL != '' }}
69+
run: |
70+
curl -s -X POST "$SLACK_WEBHOOK_URL" \
71+
-H 'Content-type: application/json' \
72+
--data "{\"text\":\"*Codeplain Client*: Install script deploy to R2 FAILED :x: (\`${GITHUB_SHA:0:7}\`). Users may be getting a stale installer. See <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|the run log>.\"}"
73+

.github/workflows/publish-to-pypi.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,22 @@ jobs:
1515
permissions:
1616
contents: write
1717

18+
env:
19+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
20+
1821
steps:
1922
- uses: actions/checkout@v4
2023
with:
2124
# hatch-vcs derives the version from git tags, so we need full history.
2225
fetch-depth: 0
2326

27+
- name: Notify Slack (start)
28+
if: ${{ env.SLACK_WEBHOOK_URL != '' }}
29+
run: |
30+
curl -s -X POST "$SLACK_WEBHOOK_URL" \
31+
-H 'Content-type: application/json' \
32+
--data "{\"text\":\"*Codeplain Client*: Release \`${{ github.ref_name }}\` published by *${{ github.actor }}* — building and publishing to PyPI...\"}"
33+
2434
- name: Install uv
2535
# uv provisions its own Python (honoring requires-python), so no
2636
# separate actions/setup-python step is needed.
@@ -47,6 +57,13 @@ jobs:
4757
run: |
4858
gh release upload ${{ github.ref_name }} dist/* --clobber
4959
60+
- name: Notify Slack (build failure)
61+
if: ${{ failure() && env.SLACK_WEBHOOK_URL != '' }}
62+
run: |
63+
curl -s -X POST "$SLACK_WEBHOOK_URL" \
64+
-H 'Content-type: application/json' \
65+
--data "{\"text\":\"*Codeplain Client*: Build of \`${{ github.ref_name }}\` FAILED :x:. Nothing was published to PyPI. See <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|the run log>.\"}"
66+
5067
publish-to-pypi:
5168
name: Publish to PyPI
5269
needs: build
@@ -59,6 +76,9 @@ jobs:
5976
# authenticate this run — no long-lived API token needed.
6077
id-token: write
6178

79+
env:
80+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
81+
6282
steps:
6383
- name: Download distribution packages
6484
uses: actions/download-artifact@v4
@@ -68,3 +88,17 @@ jobs:
6888

6989
- name: Publish to PyPI
7090
uses: pypa/gh-action-pypi-publish@release/v1
91+
92+
- name: Notify Slack (success)
93+
if: ${{ success() && env.SLACK_WEBHOOK_URL != '' }}
94+
run: |
95+
curl -s -X POST "$SLACK_WEBHOOK_URL" \
96+
-H 'Content-type: application/json' \
97+
--data "{\"text\":\"*Codeplain Client*: \`${{ github.ref_name }}\` published to PyPI :white_check_mark:. Install with \`pip install --upgrade codeplain\`.\"}"
98+
99+
- name: Notify Slack (failure)
100+
if: ${{ failure() && env.SLACK_WEBHOOK_URL != '' }}
101+
run: |
102+
curl -s -X POST "$SLACK_WEBHOOK_URL" \
103+
-H 'Content-type: application/json' \
104+
--data "{\"text\":\"*Codeplain Client*: Publishing \`${{ github.ref_name }}\` to PyPI FAILED :x:. See <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|the run log>.\"}"

0 commit comments

Comments
 (0)