Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set `run-name` conditionally in a github workflow

Tags:

github

Is it possible to conditionally set run-name in a github workflow? My workflow can either be triggered from the current repo (ci-systems) with the use of workflow_dispatch, or through the use of workflow_call from another repo's workflow_dispatch.

I would love to do something like the following to have the run-name set as My Regression tests: Version_A + ci-systems: my_branch for example.

name: my tests
run-name: >-
  if [[ ${{ github.event.repository.name }} == "ci-systems" ]]; then
    My Regression tests: ${{ inputs.my_version }} + ci-systems: ${{ github.head_ref || github.ref_name }}
  else
    My Regression tests: ${{ inputs.my_version }}


on:
  workflow_call:
    inputs:
      my_version:
        type: string
        default: Version_O
  workflow_dispatch:
    inputs:
      my_version:
        type: string
        default: Version_X
like image 660
Annemie 27 Avatar asked Apr 16 '26 05:04

Annemie 27


1 Answers

Solution is found to be:

run-name: >-
  ${{ github.event.repository.name == 'ci-systems'
    && format('My Regression tests: drv:{0} + ci-systems:{1}',
              inputs.my_version,
              github.head_ref || github.ref_name)
    || format('My Regression tests: {0}', inputs.my_version) }}
like image 51
Annemie 27 Avatar answered Apr 28 '26 00:04

Annemie 27



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!