A GitHub Action to dynamically add, update, or delete choices from workflow_dispatch input options in your repository workflows.
- Add new choices to workflow input options
- Update existing choices to new values
- Delete choices from workflow inputs
- Supports updating multiple workflows at once
name: Add Environment
on:
workflow_dispatch:
inputs:
new-environment:
description: 'New environment name to add'
required: true
type: string
jobs:
add-choice:
runs-on: ubuntu-latest
steps:
- name: Add environment choice
uses: allankp/dynamic-workflow-choices@v2.0.0 # x-release-please-version
with:
action: add
input-name: environment
workflows: deploy.yml
choice-value: ${{ inputs.new-environment }}
github-token: ${{ secrets.GITHUB_TOKEN }}- name: Delete old environment
uses: allankp/dynamic-workflow-choices@v2.0.0 # x-release-please-version
with:
action: delete
input-name: environment
workflows: deploy.yml,release.yml
choice-value: deprecated-env
github-token: ${{ secrets.GITHUB_TOKEN }}- name: Rename environment
uses: allankp/dynamic-workflow-choices@v2.0.0 # x-release-please-version
with:
action: update
input-name: environment
workflows: deploy.yml
choice-value: staging
new-choice-value: stage
github-token: ${{ secrets.GITHUB_TOKEN }}| Input | Description | Required | Default |
|---|---|---|---|
action |
Action to perform: add, update, or delete |
Yes | - |
input-name |
Name of the workflow input to modify | Yes | - |
workflows |
Comma-separated list of workflow files to update | Yes | - |
choice-value |
The choice value to add, update, or delete | Yes | - |
new-choice-value |
New value (required for update action) |
No | - |
github-token |
GitHub token with repo write permissions | Yes | ${{ github.token }} |
commit-message |
Custom commit message | No | chore: update workflow input choices |
branch |
Branch to commit changes to | No | Current branch |
| Output | Description |
|---|---|
updated-workflows |
Comma-separated list of workflows that were updated |
changes-made |
Whether any changes were made (true or false) |
The workflow using this action needs:
- Write permissions to the repository contents
- A target workflow with
workflow_dispatchtrigger andchoicetype inputs
The workflows you're updating should have inputs like this:
name: Deploy
on:
workflow_dispatch:
inputs:
environment:
description: 'Target environment'
required: true
type: choice
options:
- development
- staging
- productionYou may need to grant additional permissions to the GITHUB_TOKEN:
permissions:
contents: writeOr use a Personal Access Token (PAT) with repo scope for cross-repository updates.
- Node.js 20+
- npm
# Install dependencies
npm install
# Run tests
npm test
# Build
npm run build
# Run all checks
npm run allContributions are welcome! Please see CONTRIBUTING.md for details.
MIT License - see LICENSE for details.