Avoid failing label removal if label is not there
authorTomas Mraz <tomas@openssl.org>
Mon, 17 May 2021 17:00:13 +0000 (19:00 +0200)
committerPauli <pauli@openssl.org>
Wed, 19 May 2021 03:08:27 +0000 (13:08 +1000)
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15309)

.github/workflows/fips-label.yml

index 948ff10b3ea317146acfefd60b82c8dc6f850e44..536b2272606f246888e2351c1445b404901c80ef 100644 (file)
@@ -19,7 +19,7 @@ jobs:
             var artifacts = await github.actions.listWorkflowRunArtifacts({
               owner: context.repo.owner,
               repo: context.repo.repo,
-              run_id: ${{github.event.workflow_run.id }},
+              run_id: ${{ github.event.workflow_run.id }},
             });
             if ( artifacts.data.artifacts[0].name == 'fips_changed' ) {
               github.issues.addLabels({
@@ -29,10 +29,20 @@ jobs:
                 labels: ['severity: fips change']
               });
             } else if ( artifacts.data.artifacts[0].name == 'fips_unchanged' ) {
-              github.issues.removeLabel({
+              var labels = await github.issues.listLabelsOnIssue({
                 issue_number: ${{ github.event.workflow_run.pull_requests[0].number }},
                 owner: context.repo.owner,
                 repo: context.repo.repo,
-                name: 'severity: fips change'
               });
+
+              for ( var label in labels.data ) {
+                if (labels.data[label].name == 'severity: fips change') {
+                  github.issues.removeLabel({
+                    issue_number: ${{ github.event.workflow_run.pull_requests[0].number }},
+                    owner: context.repo.owner,
+                    repo: context.repo.repo,
+                    name: 'severity: fips change'
+                  });
+                }
+              }
             }