3

How to add custom default value for github actions

I want something like

on:
  workflow_dispatch:
    inputs:
      release_notes:
        description: 'Release Notes'
        required: false
        default: "Build by: ${{github.actor}}" #Doesn't works
Saranjith
  • 11,242
  • 5
  • 69
  • 122
  • For what I checked and tested here, it doesn't seem possible to use variables from the GitHub context at this level in the workflow. According to what the [official documentation states](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onworkflow_dispatchinputs), the only types supported are `choice`, `boolean` and `string` (where `string` is the default type if not informed). Dynamic/Custom values using the context don't seem to be supported (yet?). – GuiFalourd Jun 09 '22 at 12:56
  • 1
    There might be a workaround using a env variable at the workflow root level, checking for the input to use a default value if not filled, but it's not the best solution. Here is the [workflow file I tested](https://github.com/GuillaumeFalourd/poc-github-actions/blob/main/.github/workflows/workflow-tester38.yml) if you want to see an example, and here is a [workflow run example](https://github.com/GuillaumeFalourd/poc-github-actions/runs/6812977356?check_suite_focus=true) using it. – GuiFalourd Jun 09 '22 at 12:59
  • I want to display it as a placeholder in input field – Saranjith Jun 09 '22 at 13:26
  • In that case, you could eventually use a specific string value as reference in the placeholder, and if this string value is used as input, substitute it in your workflow by the `github.actor` context variable. – GuiFalourd Jun 09 '22 at 14:05

0 Answers0