Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider adding an "Alternatives" section that shows the ternary hack #25

Open
jcbhmr opened this issue Apr 2, 2024 · 1 comment
Open

Comments

@jcbhmr
Copy link

jcbhmr commented Apr 2, 2024

Would be good to show why/when you should/could use this action instead of the ternary hack

steps:
  - uses: actions/checkout@v3
  - run: npm run build ${{ inputs.production && '--production' || '' }}
    # => adds '--production' if box is checked, '' if not

Other good things that could be linked to:

Want to explain and answer this question: Why would a user use this:

steps:
- uses: haya14busa/action-cond@v1
  id: condval
  with:
    cond: ${{ github.event_name == 'pull_request' }}
    if_true: "value for pull request event"
    if_false: "value for non pull request event"
- name: Use conditional value
  run: echo "${{ steps.condval.outputs.value }}"

instead of this?

steps:
  - run: echo "$VALUE"
    env:
      VALUE: |
        ${{ github.event_name == 'pull_request'
          && 'value for pull request event'
          || 'value for non pull request event }}

Something like "if you have a lot of chained if conditions this action is a good fit for you" or something would be quite helpful.

@jannikschaper
Copy link

Especially considering GitHub officially documents this feature as "ternary operator like behavior" (src):

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants