This is an automated email from the ASF dual-hosted git repository.

janc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
     new d19b64f03 ci: No fail verdicts on remove workflow
d19b64f03 is described below

commit d19b64f0354f45272eeb70c507c110a29e759154
Author: Szymon Czapracki <[email protected]>
AuthorDate: Fri Oct 24 16:28:30 2025 +0200

    ci: No fail verdicts on remove workflow
    
    Organization permission in this repo
    do not allow token to remove labels.
    We will keep the workflow knowing that
    running it produces errors but we
    omit them.
---
 .github/workflows/remove_ci_label.yml | 31 ++++++++++++++++++++++---------
 1 file changed, 22 insertions(+), 9 deletions(-)

diff --git a/.github/workflows/remove_ci_label.yml 
b/.github/workflows/remove_ci_label.yml
index de70a267b..a640d9a98 100644
--- a/.github/workflows/remove_ci_label.yml
+++ b/.github/workflows/remove_ci_label.yml
@@ -34,12 +34,25 @@ jobs:
         with:
           script: |
             const label = 'needs-ci-approval';
+            const pr = context.payload.pull_request;
+            if (!pr) {
+              core.info('No pull_request in event payload. Skipping.');
+              return;
+            }
+            const issue_number = pr.number;
 
-            // List current labels on the PR
-            const { data: labels } = await 
github.rest.issues.listLabelsOnIssue({
-              ...context.repo,
-              issue_number: context.issue.number,
-            });
+            // List current labels on the PR (use PR number from payload)
+            let labels = [];
+            try {
+              const res = await github.rest.issues.listLabelsOnIssue({
+                ...context.repo,
+                issue_number,
+              });
+              labels = res.data || [];
+            } catch (e) {
+              core.info(`Could not list labels on PR #${issue_number}: 
${e.status || ''} ${e.message}. Skipping.`);
+              return;
+            }
 
             const hasLabel = labels.some(l => l.name === label);
             if (!hasLabel) {
@@ -47,18 +60,18 @@ jobs:
               return;
             }
 
-            // Remove the label if present
+            // Remove if label is present
             try {
               await github.rest.issues.removeLabel({
                 ...context.repo,
-                issue_number: context.issue.number,
+                issue_number,
                 name: label,
               });
-              core.info(`Removed '${label}' from PR 
#${context.issue.number}.`);
+              core.info(`Removed '${label}' from PR #${issue_number}.`);
             } catch (e) {
               if (e.status === 404) {
                 core.info(`'${label}' already gone.`);
               } else {
-                throw e;
+                core.info(`Failed to remove '${label}' on PR #${issue_number}: 
${e.status || ''} ${e.message}. Skipping.`);
               }
             }

Reply via email to