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
368 stars 48 forks source link

[DOCS]: handleError example does not handle errors #208

Closed andy-maier closed 1 year ago

andy-maier commented 1 year ago

Describe the need

The current handleError examle has these steps:

jobs:
  handleError:
    runs-on: ubuntu-latest
    steps:
      - uses: octokit/request-action@v2.x
        id: get_release
        with:
          route: GET /repos/{owner}/{repo}/releases/v0.9.9
          owner: octokit
          repo: request-action
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      - run: "echo Release found: ${{ steps.get_release.outputs.data }}"
      - run: "echo Release could not be found. Request failed with status ${{ steps.get_release.outputs.status }}"
        if: ${{ failure() }}

The issue with that is that the first step will cause the workflow to end with failure if the release does not exist, so the second and third step will never be run to handle the error.

SDK Version

octokit/request-action@v2.1.7

API Version

No response

Relevant log output

No response

Code of Conduct

gr2m commented 1 year ago

That's what this line is for

if: ${{ failure() }}

E.g. see this example from GitHub's Workflow Syntax docs

I'm going to close the issue as I think this should answer your question, but please let me know if I missed something