How to pre-fill an input field in a workflow_dispatch Github action with GITHUB-SHA

Viewed 1118

I'm trying to build a workflow_dispatch (ie manual) Github action that pre-fills the input fields with the SHA of the branch.

ie

name: Manually tag a release
on: 
  workflow_dispatch:
    inputs:
      git-sha:
        description: Release SHA
        default: <prefill with GITHUB_SHA>
        required: true

I've tried default: ${{ github.sha }} but that throws an error.

Is this possible and what is the syntax?

1 Answers

I just solved this problem a couple of days ago, but in a different way.

I set the required to false and then coalesced the input with the GITHUB_SHA

name: Deploy To PROD

on: 
  workflow_dispatch:
    inputs:
      sha:
        description: 'Git SHA to Deploy'

jobs:
  deploy_prod:
    runs-on: ubuntu-latest
    env:
      SHA_TO_DEPLOY: ${{ github.event.inputs.sha || github.sha }}

Then ${{ env.SHA_TO_DEPLOY }} references the SHA that was passed in, or the default if none was passed in.

Related