octokit / request-action

A GitHub Action to send arbitrary requests to GitHub's REST API
https://github.com/marketplace/actions/GitHub-API-Request
MIT License
382 stars 47 forks source link

[FEAT]: Add fail_on_error option to suppress failing #288

Open Uzlopak opened 11 months ago

Uzlopak commented 11 months ago

Describe the need

I have a workflow, where i remove a label from a PR. It would be good to add an option to the action.yml which just outputs a warning and not a failure, so e.g. if the label is already removed it does not show an error in the overview.

If we agree on the name of the option, I would provide a PR.

SDK Version

No response

API Version

No response

Relevant log output

No response

Code of Conduct

github-actions[bot] commented 11 months ago

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

andy-maier commented 1 month ago

I would like to second this request.

We have a workflow that determines whether a release exists:

    - name: Determine whether release on Github exists for the pushed tag
      id: set-release-exists
      uses: octokit/request-action@v2.x
      with:
        route: GET /repos/${{ github.repository }}/releases/tags/${{ steps.set-tag.outputs.result }}
      continue-on-error: true
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

When the release does not exist, the plugin errors out with HTTP status 404, but the continue-on-error: true causes the job to continue, and we can access the status output of this step as a condition in subsequent steps.

So the functionality works - however, we get the error reported in the actions summary, which looks bad:

Build and publish to PyPI
Not Found - https://docs.github.com/rest/releases/releases#get-a-release-by-tag-name

When the new option is specified to the plugin, any error status (e.g. 404) should no longer be returned as an error, but should still be accessible in the status output parameter.

Our complete workflow is here: https://github.com/zhmcclient/python-zhmcclient/blob/master/.github/workflows/publish.yml

andy-maier commented 1 month ago

@Uzlopak Aras, if you are still willing to create a PR for this, I guess an option named "fail_on_error" with a default of true would be a good start. If the project owners want something different, it will come up in the PR review.