Ternary based on if workflow was triggered through dispatch or not

I have the following workflow that I’d like to trigger either via a workflow dispatch event and via CRON/Push events.

name: integration-tests
on:
  workflow_dispatch:
    inputs:
      branch:
        description: 'Specifies the branch which the integration tests should run on.'
        required: true
        default: 'release'
  schedule:
    - cron: 30 15 * * 0-6
  push:
    tags-ignore:
      - '*.*'
    branches:
      - release

jobs:
  # Deploys cross repo with an access token.
  integration-cross-repo-push:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Build and Deploy
        uses: action/deployment@release

I’d like to replace action/deployment@release with the input from the workflow dispatch, ie action/deployment@${{ github.event.inputs.branch }}, but if it’s triggered via any other workflow type it should default to @release. Is there a proper way to have a ternary operator inline within a workflow that’s something like github.event.inputs.branch ? github.event.inputs.branch : 'release'?

Any help would be appreciated!

:wave: Hey @jamesives,

We don’t support using expressions within a uses: block, so you’ll need to hard-code the version of the action you’re trying to reference.

Additionally, we don’t have any support for ternary expressions.

You could do something similar in a bash script or with actions/github-script with a step output to get similar behavior.

Example:

- uses: actions/github-script@v4
  id: set-result
  with:
    script: return '${{ github.event.inputs.branch }}' || 'release' 
    result-encoding: string

- name: Get result
  run: echo "${{steps.set-result.outputs.result}}"

https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-output-parameter