octokit / request-action

A GitHub Action to send arbitrary requests to GitHub's REST API

Home Page:https://github.com/marketplace/actions/GitHub-API-Request

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[DOCS]: handleError example does not handle errors

andy-maier opened this issue · comments

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

  • I agree to follow this project's Code of Conduct

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