0

Using actions/importer-issue-ops Template and using multiple Runners with matrix strategy (ubuntu-latest,selfhosted-runner)

In the Cleanup step using below yml script to removeLabel for an issue.

     - uses: actions/github-script@v6
        if: always() 
        with:
          script: | 
             await github.rest.issues.removeLabel({
              owner: context.repo.owner,
              repo: context.repo.repo,
              issue_number: context.issue.number,
              name: 'actions-importer-running'
             });

As we are using multiple runners the ubuntu-latest runner code able to identify the label and deleting properly, whereas selfhosted-runner failed to delete because it was already deleted by ubuntu-latest.

Error message:

RequestError [HttpError]: Label does not exist
Error: Unhandled error: HttpError: Label does not exist

Trying to add condition to verify the label and deleting, looking for the solution to add some condition which will verify the label and initiate removeLabel if exists.

Thanks in advance!

Tried octokit/rest.js and other available actions but couldn't solve the problem.

Azeem
  • 11,148
  • 4
  • 27
  • 40
Naresh
  • 1
  • 1
  • You can add a condition e.g. `if: ${{ matrix.os == 'ubuntu-latest' }}` to remove label from one specific runner only. – Azeem Jun 28 '23 at 16:16
  • Thank you @azeem but the runners are often changing and suppose to not set hardcoded values any suggestions. – Naresh Jun 30 '23 at 04:55
  • Well, you can first get the label to make sure it exists and then delete it. Or, you can simply mark these steps [`continue-on-error: true`](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepscontinue-on-error). Or, you can get the result from that API call, analyze its result, log properly, and just return a success status as not to fail it. – Azeem Jun 30 '23 at 05:03

0 Answers0