Skip to content

Commit 59d20df

Browse files
committed
chore: upgrade PostHog GitHub Action to v1
1 parent 3c0c17f commit 59d20df

1 file changed

Lines changed: 36 additions & 7 deletions

File tree

.github/workflows/release.yml

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ jobs:
6262
name: Release and publish
6363
needs: [check-release-label, notify-approval-needed]
6464
runs-on: ubuntu-latest
65+
outputs:
66+
new-version: ${{ steps.sampo-release.outputs.new_version }}
6567
# Use `always()` to ensure the job runs even if notify-approval-needed is skipped,
6668
# but still depend on it to access `needs.notify-approval-needed.outputs.slack_ts`
6769
if: always() && needs.check-release-label.outputs.should-release == 'true'
@@ -201,29 +203,56 @@ jobs:
201203
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
202204
run: gh workflow run generate-references.yml --ref main
203205

204-
# Notify in case of a failure
206+
notify-failed:
207+
name: Notify release failure
208+
needs: [check-release-label, notify-approval-needed, release]
209+
runs-on: ubuntu-latest
210+
# Keep failure reporting in a separate job so it still runs when `release`
211+
# fails during job setup, before any of that job's steps can execute.
212+
if: always() && needs.check-release-label.outputs.should-release == 'true' && needs.release.result == 'failure'
213+
steps:
205214
- name: Send failure event to PostHog
206-
if: ${{ failure() }}
207-
uses: PostHog/posthog-github-action@v0.1
215+
uses: PostHog/posthog-github-action@v1
208216
with:
209217
posthog-token: "${{ secrets.POSTHOG_PROJECT_API_KEY }}"
210218
event: "posthog-python-github-release-workflow-failure"
219+
github-token: ${{ secrets.GITHUB_TOKEN }}
220+
status-job: "Release and publish"
221+
capture-run-duration: true
211222
properties: >-
212223
{
213224
"commitSha": "${{ github.sha }}",
214-
"jobStatus": "${{ job.status }}",
225+
"jobStatus": "${{ needs.release.result }}",
215226
"ref": "${{ github.ref }}",
216-
"version": "${{ steps.sampo-release.outputs.new_version }}"
227+
"version": "${{ needs.release.outputs.new-version }}"
217228
}
218229
230+
- name: Build Slack failure message
231+
if: needs.notify-approval-needed.outputs.slack_ts != ''
232+
id: failure-message
233+
env:
234+
RELEASE_VERSION: ${{ needs.release.outputs.new-version }}
235+
run: |
236+
if [ -n "$RELEASE_VERSION" ]; then
237+
message="❌ Failed to release \`posthog-python@$RELEASE_VERSION\`! <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|View logs>"
238+
else
239+
message="❌ Failed to release \`posthog-python\`! <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|View logs>"
240+
fi
241+
242+
{
243+
echo 'message<<EOF'
244+
echo "$message"
245+
echo EOF
246+
} >> "$GITHUB_OUTPUT"
247+
219248
- name: Notify Slack - Failed
220-
if: ${{ failure() && needs.notify-approval-needed.outputs.slack_ts != '' }}
249+
if: needs.notify-approval-needed.outputs.slack_ts != ''
221250
uses: posthog/.github/.github/actions/slack-thread-reply@main
222251
with:
223252
slack_bot_token: ${{ secrets.SLACK_CLIENT_LIBRARIES_BOT_TOKEN }}
224253
slack_channel_id: ${{ vars.SLACK_APPROVALS_CLIENT_LIBRARIES_CHANNEL_ID }}
225254
thread_ts: ${{ needs.notify-approval-needed.outputs.slack_ts }}
226-
message: "❌ Failed to release `posthog-python@${{ steps.sampo-release.outputs.new_version }}`! <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|View logs>"
255+
message: ${{ steps.failure-message.outputs.message }}
227256
emoji_reaction: "x"
228257

229258
notify-released:

0 commit comments

Comments
 (0)