Skip to content

Commit 545eed9

Browse files
fix: always fetch fresh PR labels to avoid stale event payload data (calcom#26113)
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 parent 4088338 commit 545eed9

1 file changed

Lines changed: 26 additions & 8 deletions

File tree

.github/workflows/pr.yml

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,10 @@ jobs:
5656
with:
5757
script: |
5858
let labels = [];
59+
let prNumber = null;
5960
6061
if (context.payload.pull_request) {
61-
labels = context.payload.pull_request.labels;
62+
prNumber = context.payload.pull_request.number;
6263
} else {
6364
try {
6465
const sha = '${{ steps.get_sha.outputs.commit-sha }}';
@@ -75,20 +76,37 @@ jobs:
7576
return;
7677
}
7778
78-
const pr = prs[0];
79-
console.log(`PR number: ${pr.number}`);
80-
console.log(`PR title: ${pr.title}`);
81-
console.log(`PR state: ${pr.state}`);
82-
console.log(`PR URL: ${pr.html_url}`);
83-
84-
labels = pr.labels;
79+
prNumber = prs[0].number;
8580
}
8681
catch (e) {
8782
core.setOutput('run-e2e', false);
8883
console.log(e);
84+
return;
8985
}
9086
}
9187
88+
// Always fetch fresh PR data to get current labels
89+
// This avoids stale label data from event payloads
90+
try {
91+
const { data: pr } = await github.rest.pulls.get({
92+
owner: context.repo.owner,
93+
repo: context.repo.repo,
94+
pull_number: prNumber
95+
});
96+
97+
console.log(`PR number: ${pr.number}`);
98+
console.log(`PR title: ${pr.title}`);
99+
console.log(`PR state: ${pr.state}`);
100+
console.log(`PR URL: ${pr.html_url}`);
101+
102+
labels = pr.labels;
103+
}
104+
catch (e) {
105+
core.setOutput('run-e2e', false);
106+
console.log(e);
107+
return;
108+
}
109+
92110
const labelFound = labels.map(l => l.name).includes('ready-for-e2e');
93111
console.log('Found the label?', labelFound);
94112
core.setOutput('run-e2e', labelFound);

0 commit comments

Comments
 (0)