author avatar

vaibhav.yadav

Fri May 31 2024

Using choice Input in GitHub Actions

Choice input in Github actions can be used to provide a predefined list of options for workflow dispatch events. This makes it easier for users to select from a set of valid options when triggering workflows manually.

Example:

name: Example Workflow

on:
  workflow_dispatch:
    inputs:
      environment:
        description: 'Select the environment'
        required: true
        default: 'sandbox'
        type: choice
        options:
          - sandbox
          - uat
          - production

jobs:
  example_job:
    runs-on: ubuntu-latest
    steps:
      - name: Display Inputs
        run: |
          echo "Environment: ${{ github.event.inputs.environment }}"

#githubactions #devops #automation #dropdown