Skip to content

Commit 4210ae6

Browse files
authored
Fix Slack notification for release notes PRs from forks (#24566)
## Description The Slack notification workflow for Desktop release notes PRs fails when the PR is opened from a fork because GitHub doesn't expose repository secrets to `pull_request` events from forks. This PR splits the workflow into two: 1. **Release Notes PR Trigger** — runs on `pull_request`, saves PR details (URL, title, author) as an artifact. No secrets needed. 2. **Notify Slack on Desktop Release Notes PR** — runs on `workflow_run` after the trigger completes, downloads the artifact, and sends the Slack notification. Has access to secrets since `workflow_run` runs in the context of the base repository. ## Related issues or tickets Fixes the `SlackError: Missing input! A token must be provided` error in the notify-release-notes-pr workflow. ## Reviews - [x] Technical review Signed-off-by: Lorena Rangel <lorena.rangel@docker.com>
1 parent 7ae0e55 commit 4210ae6

2 files changed

Lines changed: 48 additions & 7 deletions

File tree

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,29 @@
11
name: Notify Slack on Desktop Release Notes PR
22

33
on:
4-
pull_request:
5-
types: [opened]
6-
paths:
7-
- content/manuals/desktop/release-notes.md
4+
workflow_run:
5+
workflows: ["Release Notes PR Trigger"]
6+
types: [completed]
87

98
jobs:
109
notify:
1110
runs-on: ubuntu-24.04
12-
if: github.repository_owner == 'docker'
11+
if: github.repository_owner == 'docker' && github.event.workflow_run.conclusion == 'success'
1312
steps:
13+
- name: Download PR details
14+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
15+
with:
16+
name: pr-details
17+
github-token: ${{ secrets.GITHUB_TOKEN }}
18+
run-id: ${{ github.event.workflow_run.id }}
19+
20+
- name: Read PR details
21+
id: pr
22+
run: |
23+
echo "url=$(jq -r .url pr-details.json)" >> "$GITHUB_OUTPUT"
24+
echo "title=$(jq -r .title pr-details.json)" >> "$GITHUB_OUTPUT"
25+
echo "author=$(jq -r .author pr-details.json)" >> "$GITHUB_OUTPUT"
26+
1427
- name: Notify Slack
1528
uses: slackapi/slack-github-action@af78098f536edbc4de71162a307590698245be95 # v3.0.1
1629
with:
@@ -25,8 +38,8 @@ jobs:
2538
"type": "section",
2639
"text": {
2740
"type": "mrkdwn",
28-
"text": ":memo: *Desktop release notes*:\n<${{ github.event.pull_request.html_url }}|${{ github.event.pull_request.title }}> by <https://github.com/${{ github.event.pull_request.user.login }}|${{ github.event.pull_request.user.login }}>"
41+
"text": ":memo: *Desktop release notes*:\n<${{ steps.pr.outputs.url }}|${{ steps.pr.outputs.title }}> by <https://github.com/${{ steps.pr.outputs.author }}|${{ steps.pr.outputs.author }}>"
2942
}
3043
}
3144
]
32-
}
45+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Release Notes PR Trigger
2+
3+
on:
4+
pull_request:
5+
types: [opened]
6+
paths:
7+
- content/manuals/desktop/release-notes.md
8+
9+
jobs:
10+
trigger:
11+
runs-on: ubuntu-24.04
12+
if: github.repository_owner == 'docker'
13+
steps:
14+
- name: Save PR details
15+
run: |
16+
cat <<'EOF' > pr-details.json
17+
{
18+
"url": "${{ github.event.pull_request.html_url }}",
19+
"title": "${{ github.event.pull_request.title }}",
20+
"author": "${{ github.event.pull_request.user.login }}"
21+
}
22+
EOF
23+
24+
- name: Upload PR details
25+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
26+
with:
27+
name: pr-details
28+
path: pr-details.json

0 commit comments

Comments
 (0)