Github workflow_dispatch input dynamic values

I want to invoke a workflow manually and letting the user select a tag value as an input to that workflow

on:
  workflow_dispatch:
    inputs:
      DEPLOY_VERSION:
        description: 'Tag Version (0.0.1)'
        required: true
      ENV:
        type: choice
        description: 'Environment'
        required: false
        options:
          - dev
          - prodga
        default: 'dev'

jobs:
  deploy:
    name: "Deploying ${{ github.event.inputs.DEPLOY_VERSION }} to ${{ github.event.inputs.ENV }} by ${{ github.actor }}"
    runs-on: ubuntu-latest
    steps:
      - run: |
          echo "Deploying ${{ github.event.inputs.DEPLOY_VERSION }}!"
          echo "To ${{ github.event.inputs.ENV }}!"

I want to invoke a workflow manually and letting the user select a tag value as an input to that workflow

on:
  workflow_dispatch:
    inputs:
      DEPLOY_VERSION:
        description: 'Tag Version (0.0.1)'
        required: true
      ENV:
        type: choice
        description: 'Environment'
        required: false
        options:
          - dev
          - prodga
        default: 'dev'

jobs:
  deploy:
    name: "Deploying ${{ github.event.inputs.DEPLOY_VERSION }} to ${{ github.event.inputs.ENV }} by ${{ github.actor }}"
    runs-on: ubuntu-latest
    steps:
      - run: |
          echo "Deploying ${{ github.event.inputs.DEPLOY_VERSION }}!"
          echo "To ${{ github.event.inputs.ENV }}!"

Is there a way instead of manually enter the value for the tag it can fetch a list of lets say 100 last tag . Or for type: choice the options must be hard coded?

5 Likes

I am in a similar situation (though admittedly the option I want to be dynamic is selecting a particular file in a folder).
A solution I know is possible (though I haven’t gotten around to it yet) is to use either a pre-commit git hook, or a pre-receive git hook (only usable on github-enterprise), and basically have your workflow scripts generated on commit using some form of templating.
I admit it isn’t as automated, but in theory shouldn’t be too difficult, additionally you could setup a template to use for git init such that it’s always included

Anyone gotten around the suggested solution or different solution?

This post was flagged by the community and is temporarily hidden.