Skip to content

Commit 4bc1d4a

Browse files
authored
chore: fix job url in slack notifications (#2707)
* chore: add job URL retrieval step to multiple workflows for improved Slack notifications * chore: move checkout above * chore: add debug log * chore: use runner naem * chore: revert temp changes * chore: implement fallback url * chore: fix fallback url
1 parent 78d98e7 commit 4bc1d4a

6 files changed

Lines changed: 61 additions & 7 deletions

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: 'Get Job URL'
2+
description: 'Fetches the direct URL to the current GitHub Actions job'
3+
4+
inputs:
5+
github_token:
6+
description: 'GitHub token for API access'
7+
required: false
8+
default: ${{ github.token }}
9+
10+
outputs:
11+
job_url:
12+
description: 'Direct URL to the current job in GitHub Actions UI'
13+
value: ${{ steps.get-job-url.outputs.job_url }}
14+
15+
runs:
16+
using: 'composite'
17+
steps:
18+
- name: Get Job URL
19+
id: get-job-url
20+
shell: bash
21+
env:
22+
GH_TOKEN: ${{ inputs.github_token }}
23+
run: |
24+
jobs=$(gh api repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/jobs)
25+
job_url=$(echo "$jobs" | jq -r '.jobs[] | select(.runner_name=="${{ runner.name }}") | .html_url')
26+
if [ -z "$job_url" ] || [ "$job_url" = "null" ]; then
27+
job_url=${{ format('{0}/{1}/actions/runs/{2}', github.server_url, github.repository, github.run_id) }}
28+
fi
29+
echo "job_url=$job_url" >> $GITHUB_OUTPUT

.github/workflows/deploy-npm.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,11 @@ jobs:
214214
run: |
215215
npm deprecate rudder-sdk-js "This package is deprecated and no longer maintained. While your events are still being tracked and delivered, we strongly recommend you to migrate to the latest package, @rudderstack/analytics-js (https://www.npmjs.com/package/@rudderstack/analytics-js), for the latest features, security updates, and improved performance. For more details, visit the migration guide: https://www.rudderstack.com/docs/sources/event-streams/sdks/rudderstack-javascript-sdk/migration-guide/."
216216
217+
- name: Get Job URL
218+
id: get-job-url
219+
continue-on-error: true
220+
uses: ./.github/actions/get-job-url
221+
217222
- name: Send message to Slack channel
218223
if: env.CURRENT_NPM_VERSION != env.NEW_NPM_VERSION && env.NEW_NPM_VERSION != 'not found'
219224
id: slack
@@ -223,7 +228,7 @@ jobs:
223228
PROJECT_NAME: ${{ format('JS SDK NPM Package{0}', (inputs.environment == 'staging' && ' - Staging') || (inputs.environment == 'development' && ' - Development') || (inputs.environment == 'beta' && ' - Beta') || '') }}
224229
NPM_PACKAGE_URL: ${{ format('https://www.npmjs.com/package/@rudderstack/analytics-js/v/{0}', env.CURRENT_VERSION_VALUE) }}
225230
RELEASES_URL: 'https://github.com/rudderlabs/rudder-sdk-js/releases/tag/@rudderstack/analytics-js@'
226-
GITHUB_RUN_URL: ${{ format('{0}/{1}/actions/runs/{2}/jobs/{3}', github.server_url, github.repository, github.run_id, github.job) }}
231+
GITHUB_RUN_URL: ${{ steps.get-job-url.outputs.job_url }}
227232
ACTOR_URL: ${{ format('{0}/{1}', github.server_url, github.actor) }}
228233
ACTOR: ${{ github.actor }}
229234
with:
@@ -294,7 +299,7 @@ jobs:
294299
PROJECT_NAME: ${{ format('JS SDK Service Worker NPM Package{0}', (inputs.environment == 'staging' && ' - Staging') || (inputs.environment == 'development' && ' - Development') || (inputs.environment == 'beta' && ' - Beta') || '') }}
295300
NPM_PACKAGE_URL: ${{ format('https://www.npmjs.com/package/@rudderstack/analytics-js-service-worker/v/{0}', env.CURRENT_VERSION_SW_VALUE) }}
296301
RELEASES_URL: 'https://github.com/rudderlabs/rudder-sdk-js/releases/tag/@rudderstack/analytics-js-service-worker@'
297-
GITHUB_RUN_URL: ${{ format('{0}/{1}/actions/runs/{2}/jobs/{3}', github.server_url, github.repository, github.run_id, github.job) }}
302+
GITHUB_RUN_URL: ${{ steps.get-job-url.outputs.job_url }}
298303
ACTOR_URL: ${{ format('{0}/{1}', github.server_url, github.actor) }}
299304
ACTOR: ${{ github.actor }}
300305
with:
@@ -354,7 +359,7 @@ jobs:
354359
PROJECT_NAME: ${{ format('JS SDK Cookies Utilities{0}', (inputs.environment == 'staging' && ' - Staging') || (inputs.environment == 'development' && ' - Development') || (inputs.environment == 'beta' && ' - Beta') || '') }}
355360
NPM_PACKAGE_URL: ${{ format('https://www.npmjs.com/package/@rudderstack/analytics-js-cookies/v/{0}', env.CURRENT_VERSION_COOKIE_UTILS_VALUE) }}
356361
RELEASES_URL: 'https://github.com/rudderlabs/rudder-sdk-js/releases/tag/@rudderstack/analytics-js-cookies@'
357-
GITHUB_RUN_URL: ${{ format('{0}/{1}/actions/runs/{2}/jobs/{3}', github.server_url, github.repository, github.run_id, github.job) }}
362+
GITHUB_RUN_URL: ${{ steps.get-job-url.outputs.job_url }}
358363
ACTOR_URL: ${{ format('{0}/{1}', github.server_url, github.actor) }}
359364
ACTOR: ${{ github.actor }}
360365
with:

.github/workflows/deploy-sanity-suite.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,11 @@ jobs:
161161
run: |
162162
AWS_MAX_ATTEMPTS=10 aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CF_DISTRIBUTION_ID }} --paths "/sanity-suite${{ env.SUITE_CDN_PATH }}*"
163163
164+
- name: Get Job URL
165+
id: get-job-url
166+
continue-on-error: true
167+
uses: ./.github/actions/get-job-url
168+
164169
- name: Send message to Slack channel
165170
id: slack
166171
uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # v2.1.1
@@ -169,7 +174,7 @@ jobs:
169174
PROJECT_NAME: ${{ format('Sanity Suite - {0}', (inputs.environment == 'production' && 'Production') || (inputs.environment == 'staging' && 'Staging') || (inputs.environment == 'development' && 'Development') || 'Beta') }}
170175
CDN_URL: '${{ inputs.base_cdn_url }}/sanity-suite${{ env.SUITE_CDN_PATH }}/v3/cdn/index.html'
171176
LINK_TEXT: ${{ ((inputs.environment == 'development' && format('v{0} - Development', env.CURRENT_VERSION_VALUE)) || (inputs.environment == 'staging' && format('v{0} - Staging', env.CURRENT_VERSION_VALUE)) || (inputs.environment == 'beta' && format('v{0} - Beta', env.CURRENT_VERSION_VALUE)) || format('v{0}', env.CURRENT_VERSION_VALUE)) }}
172-
GITHUB_RUN_URL: ${{ format('{0}/{1}/actions/runs/{2}/jobs/{3}', github.server_url, github.repository, github.run_id, github.job) }}
177+
GITHUB_RUN_URL: ${{ steps.get-job-url.outputs.job_url }}
173178
ACTOR_URL: ${{ format('{0}/{1}', github.server_url, github.actor) }}
174179
ACTOR: ${{ github.actor }}
175180
with:

.github/workflows/deploy.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,11 @@ jobs:
290290
291291
aws cloudfront wait invalidation-completed --distribution-id ${{ secrets.AWS_CF_DISTRIBUTION_ID }} --id "$invalidation_id"
292292
293+
- name: Get Job URL
294+
id: get-job-url
295+
continue-on-error: true
296+
uses: ./.github/actions/get-job-url
297+
293298
- name: Send message to Slack channel
294299
id: slack
295300
continue-on-error: true
@@ -299,7 +304,7 @@ jobs:
299304
CDN_URL: ${{ format('{0}/{1}/modern/rsa.min.js', inputs.base_cdn_url, inputs.s3_dir_path) }}
300305
RELEASES_URL: 'https://github.com/rudderlabs/rudder-sdk-js/releases/tag/@rudderstack/analytics-js@'
301306
LINK_TEXT: ${{ (inputs.environment == 'development' && 'Development') || (inputs.environment == 'staging' && format('v{0} - Staging', env.CURRENT_VERSION_VALUE)) || format('v{0}', env.CURRENT_VERSION_VALUE) }}
302-
GITHUB_RUN_URL: ${{ format('{0}/{1}/actions/runs/{2}/jobs/{3}', github.server_url, github.repository, github.run_id, github.job) }}
307+
GITHUB_RUN_URL: ${{ steps.get-job-url.outputs.job_url }}
303308
ACTOR: ${{ github.actor }}
304309
ACTOR_URL: ${{ format('{0}/{1}', github.server_url, github.actor) }}
305310
with:

.github/workflows/publish-new-release.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,11 @@ jobs:
206206
--title "$pr_title" \
207207
--body-file pr_body.md
208208
209+
- name: Get Job URL
210+
id: get-job-url
211+
continue-on-error: true
212+
uses: ./.github/actions/get-job-url
213+
209214
- name: Send message to Slack channel
210215
id: slack
211216
if: always()
@@ -215,7 +220,7 @@ jobs:
215220
PROJECT_NAME: 'JS SDK Monorepo'
216221
TAG_COMPARE_URL: 'https://github.com/rudderlabs/rudder-sdk-js/compare/'
217222
RELEASES_URL: 'https://github.com/rudderlabs/rudder-sdk-js/releases/tag/'
218-
GITHUB_RUN_URL: ${{ format('{0}/{1}/actions/runs/{2}/jobs/{3}', github.server_url, github.repository, github.run_id, github.job) }}
223+
GITHUB_RUN_URL: ${{ steps.get-job-url.outputs.job_url }}
219224
ACTOR_URL: ${{ format('{0}/{1}', github.server_url, github.actor) }}
220225
ACTOR: ${{ github.actor }}
221226
with:

.github/workflows/rollback.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@ jobs:
140140
141141
aws cloudfront wait invalidation-completed --distribution-id ${{ secrets.AWS_PROD_CF_DISTRIBUTION_ID }} --id "$invalidation_id"
142142
143+
- name: Get Job URL
144+
id: get-job-url
145+
continue-on-error: true
146+
uses: ./.github/actions/get-job-url
147+
143148
- name: Mark the rollback version as the latest GitHub release
144149
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
145150
continue-on-error: true
@@ -201,7 +206,7 @@ jobs:
201206
CDN_URL: ${{ format('https://cdn.rudderlabs.com/{0}/modern/rsa.min.js', env.LATEST_VERSION_DIR_NAME) }}
202207
RELEASES_URL: 'https://github.com/rudderlabs/rudder-sdk-js/releases/tag/@rudderstack/analytics-js@'
203208
LINK_TEXT: ${{ format('v{0}', env.ROLLBACK_VERSION_VALUE) }}
204-
GITHUB_RUN_URL: ${{ format('{0}/{1}/actions/runs/{2}/jobs/{3}', github.server_url, github.repository, github.run_id, github.job) }}
209+
GITHUB_RUN_URL: ${{ steps.get-job-url.outputs.job_url }}
205210
ACTOR_URL: ${{ format('{0}/{1}', github.server_url, github.actor) }}
206211
ACTOR: ${{ github.actor }}
207212
with:

0 commit comments

Comments
 (0)