Skip to content

Commit 0625708

Browse files
saltenaslm1so
andauthored
ci(cd): send production bump PR links to slack (#95)
* ci(cd): send production bump PR links to slack safely Move Slack notifications into the release workflow so the webhook stays in workflow secrets context for this public repo, and escape failure messages so alerts remain valid when Octopilot returns quoted or multiline errors. * ci(cd): notify slack about production bump prs safely Add Slack notifications for production config bump PRs and keep the webhook in the workflow context. Surface Octopilot outputs for the workflow and harden failure reporting against multiline errors. * ci(cd): notify slack about production bump prs safely Send Slack notifications for production config bump PRs while keeping the webhook in the workflow context, and harden Octopilot output handling so multiline failures still surface correctly. --------- Co-authored-by: Michal Baumgartner <michal.baumgartner@deepnote.com>
1 parent e0c7bd8 commit 0625708

2 files changed

Lines changed: 88 additions & 5 deletions

File tree

.github/actions/update-config-version/action.yml

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ inputs:
2121
target_repo:
2222
description: 'Target repository name'
2323
required: true
24+
outputs:
25+
pr_url:
26+
description: 'URL of the created or updated PR'
27+
value: ${{ steps.octopilot.outputs.pr_url }}
28+
error_message:
29+
description: 'Error message if octopilot failed'
30+
value: ${{ steps.octopilot.outputs.error_message }}
2431
runs:
2532
using: 'composite'
2633
steps:
@@ -70,6 +77,8 @@ runs:
7077
octopilot --version
7178
7279
- name: Update version using octopilot
80+
id: octopilot
81+
continue-on-error: true
7382
shell: bash
7483
env:
7584
GITHUB_TOKEN: ${{ inputs.github_token }}
@@ -78,11 +87,6 @@ runs:
7887
INPUT_BRANCH: ${{ inputs.branch }}
7988
INPUT_MERGE: ${{ inputs.merge }}
8089
INPUT_VERSIONS: ${{ inputs.versions }}
81-
GITHUB_SERVER_URL: ${{ github.server_url }}
82-
GITHUB_REPOSITORY: ${{ github.repository }}
83-
GITHUB_RUN_ID: ${{ github.run_id }}
84-
GITHUB_SHA: ${{ github.sha }}
85-
GITHUB_ACTOR: ${{ github.actor }}
8690
run: |
8791
set -euo pipefail
8892
@@ -253,4 +257,33 @@ runs:
253257
"--fail-on-error"
254258
)
255259
260+
set +e
256261
octopilot "${octopilot_args[@]}"
262+
OCTOPILOT_EXIT_CODE=$?
263+
set -e
264+
265+
# Extract PR URL and error message from octopilot output
266+
PR_URL=""
267+
ERROR_MESSAGE=""
268+
OUTPUT_DELIMITER="GITHUB_OUTPUT_$(uuidgen)"
269+
if [[ -f octopilot-output.json ]]; then
270+
PR_URL="$(jq -r '.repos[0].pr.url // empty' octopilot-output.json 2>/dev/null || echo "")"
271+
ERROR_MESSAGE="$(jq -r '.repos[0].error // empty' octopilot-output.json 2>/dev/null || echo "")"
272+
echo "PR URL: $PR_URL"
273+
fi
274+
275+
if [[ -n "${GITHUB_OUTPUT:-}" ]]; then
276+
{
277+
echo "pr_url=$PR_URL"
278+
echo "error_message<<$OUTPUT_DELIMITER"
279+
echo "$ERROR_MESSAGE"
280+
echo "$OUTPUT_DELIMITER"
281+
} >> "$GITHUB_OUTPUT"
282+
fi
283+
284+
exit $OCTOPILOT_EXIT_CODE
285+
286+
- name: Fail if octopilot failed
287+
if: steps.octopilot.outcome == 'failure'
288+
shell: bash
289+
run: exit 1

.github/workflows/cd.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,7 @@ jobs:
511511
uses: ./.github/actions/export-version
512512

513513
- name: Update production version
514+
id: update-ops
514515
uses: ./.github/actions/update-config-version
515516
with:
516517
env: production
@@ -521,7 +522,32 @@ jobs:
521522
branch: master
522523
github_token: ${{ secrets.DEEPNOTE_BOT_USER_TOKEN }}
523524

525+
- name: Notify Slack - ops production PR created
526+
if: always() && steps.update-ops.outcome == 'success' && steps.update-ops.outputs.pr_url != ''
527+
uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # v2.1.1
528+
with:
529+
webhook: ${{ secrets.SLACK_WEBHOOK_PRODUCTION }}
530+
webhook-type: incoming-webhook
531+
payload: |
532+
{
533+
"icon_emoji": ":deepnote:",
534+
"text": ":loading: ${{ github.actor }} issued <https://github.com/${{ github.repository }}/releases/tag/${{ github.ref_name }}|a new release ${{ github.ref_name }}> of deepnote-toolkit on production.\nPlease <${{ steps.update-ops.outputs.pr_url }}|review, approve, and merge the version-update PR> to start the rollout."
535+
}
536+
537+
- name: Notify Slack - ops production PR failed
538+
if: always() && steps.update-ops.outcome == 'failure'
539+
uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # v2.1.1
540+
with:
541+
webhook: ${{ secrets.SLACK_WEBHOOK_PRODUCTION }}
542+
webhook-type: incoming-webhook
543+
payload: |
544+
{
545+
"icon_emoji": ":nervous-laughter:",
546+
"text": ${{ toJSON(format('Failed to create ops version-update PR for deepnote-toolkit {0}. Error: {1}', github.ref_name, steps.update-ops.outputs.error_message || 'Unknown error')) }}
547+
}
548+
524549
- name: Update app-config repo multi-tenant production version
550+
id: update-app-config
525551
uses: ./.github/actions/update-config-version
526552
with:
527553
env: production
@@ -533,3 +559,27 @@ jobs:
533559
target_repo: app-config
534560
branch: main
535561
github_token: ${{ secrets.DEEPNOTE_BOT_USER_TOKEN }}
562+
563+
- name: Notify Slack - app-config production PR created
564+
if: always() && steps.update-app-config.outcome == 'success' && steps.update-app-config.outputs.pr_url != ''
565+
uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # v2.1.1
566+
with:
567+
webhook: ${{ secrets.SLACK_WEBHOOK_PRODUCTION }}
568+
webhook-type: incoming-webhook
569+
payload: |
570+
{
571+
"icon_emoji": ":deepnote:",
572+
"text": ":loading: ${{ github.actor }} issued <https://github.com/${{ github.repository }}/releases/tag/${{ github.ref_name }}|a new release ${{ github.ref_name }}> of deepnote-toolkit on production.\nPlease <${{ steps.update-app-config.outputs.pr_url }}|review, approve, and merge the version-update PR> to start the rollout."
573+
}
574+
575+
- name: Notify Slack - app-config production PR failed
576+
if: always() && steps.update-app-config.outcome == 'failure'
577+
uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # v2.1.1
578+
with:
579+
webhook: ${{ secrets.SLACK_WEBHOOK_PRODUCTION }}
580+
webhook-type: incoming-webhook
581+
payload: |
582+
{
583+
"icon_emoji": ":nervous-laughter:",
584+
"text": ${{ toJSON(format('Failed to create app-config version-update PR for deepnote-toolkit {0}. Error: {1}', github.ref_name, steps.update-app-config.outputs.error_message || 'Unknown error')) }}
585+
}

0 commit comments

Comments
 (0)