@@ -18,24 +18,31 @@ jobs:
1818 steps :
1919 - name : Build event metadata
2020 id : metadata
21- shell : bash
22- run : |
23- set -euo pipefail
24-
25- if [[ "${{ github.event_name }}" == "issues" ]]; then
26- echo "type=Issue" >> "$GITHUB_OUTPUT"
27- echo "number=${{ github.event.issue.number }}" >> "$GITHUB_OUTPUT"
28- echo "title=${{ github.event.issue.title }}" >> "$GITHUB_OUTPUT"
29- echo "url=${{ github.event.issue.html_url }}" >> "$GITHUB_OUTPUT"
30- elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
31- echo "type=Pull Request" >> "$GITHUB_OUTPUT"
32- echo "number=${{ github.event.pull_request.number }}" >> "$GITHUB_OUTPUT"
33- echo "title=${{ github.event.pull_request.title }}" >> "$GITHUB_OUTPUT"
34- echo "url=${{ github.event.pull_request.html_url }}" >> "$GITHUB_OUTPUT"
35- else
36- echo "Unsupported event: ${{ github.event_name }}" >&2
37- exit 1
38- fi
21+ uses : actions/github-script@v7
22+ with :
23+ script : |
24+ try {
25+ const payload = context.payload;
26+ if (context.eventName === "issues" && payload.issue) {
27+ core.setOutput("type", "Issue");
28+ core.setOutput("number", String(payload.issue.number));
29+ core.setOutput("title", payload.issue.title || "(no title)");
30+ core.setOutput("url", payload.issue.html_url);
31+ return;
32+ }
33+
34+ if (context.eventName === "pull_request" && payload.pull_request) {
35+ core.setOutput("type", "Pull Request");
36+ core.setOutput("number", String(payload.pull_request.number));
37+ core.setOutput("title", payload.pull_request.title || "(no title)");
38+ core.setOutput("url", payload.pull_request.html_url);
39+ return;
40+ }
41+
42+ core.setFailed(`Unsupported event payload for "${context.eventName}".`);
43+ } catch (error) {
44+ core.setFailed(`Failed to build event metadata: ${error.message}`);
45+ }
3946
4047 - name : Post welcome comment
4148 uses : actions/github-script@v7
@@ -99,13 +106,9 @@ jobs:
99106 return "";
100107 }
101108
102- const recipientSet = new Set();
103- for (const admin of admins) {
104- const user = await github.rest.users.getByUsername({ username: admin.login });
105- const publicEmail = user?.data?.email;
106- const fallbackNoreply = `${admin.id}+${admin.login}@users.noreply.github.com`;
107- recipientSet.add(publicEmail || fallbackNoreply);
108- }
109+ const recipientSet = new Set(
110+ admins.map((admin) => `${admin.id}+${admin.login}@users.noreply.github.com`)
111+ );
109112
110113 const recipients = [...recipientSet].join(",");
111114 core.info(`Resolved ${recipientSet.size} organization owner recipient(s).`);
0 commit comments