github-actions

GitHub Actions "User input" step


Is there a way (perhaps custom step/job on the marketplace) that prompts the user for input in the middle of a workflow?

I know it is possible to define user input fields when the workflow is triggered manually - workflow_dispatch event.

However, in my environment, the workflows need to be triggered by pull requests. The logic is something like:

Is it possible to have a user input or survey step when the workflow is started automatically?


Solution

  • I'm unsure if this is still useful to you, but I created an action that does this very thing because I needed the functionality, and it didn't look like it would be on the GH roadmap for any time soon.

    https://github.com/marketplace/actions/interactive-inputs - it allows you to shape however you want your mid-workflow input to look, supporting dynamic dropdowns based on the output of other steps, file upload, integrates with slack and discord etc.

    Here's an example of how it works, integrate interactive inputs into your workflows with:

    steps:
      - name: Example Interactive Inputs Step
        id: interactive-inputs
        uses: boasihq/interactive-inputs@v2
        with:
          ngrok-authtoken: ${{ secrets.NGROK_AUTHTOKEN }}
          notifier-slack-enabled: "false"
          notifier-slack-channel: "#notifications"
          notifier-slack-token: ${{ secrets.SLACK_TOKEN }}
          notifier-discord-enabled: "false"
          notifier-discord-webhook: ${{ secrets.DISCORD_WEBHOOK }}
          timeout: 160
          title: "A batch of 10 feature flags have been added to be deployed. Would you like to proceed?"
          interactive: |
            fields:
              - label: continue-roll-out
                properties:
                  display: Continue to roll out?
                  defaultValue: 'false'
                  type: boolean
                  required: true
              - label: exclude-domains
                properties:
                  description: Select the domains to exclude from the roll out
                  display: Exclude domain(s)
                  type: multiselect
                  choices: 
                    ["Payments", "Bookings", "Notifications", "Support"]
              - label: requested-files
                properties:
                  display: Upload desired files
                  type: multifile
                  required: true
                  description: Upload desired files that are to be uploaded to the runner for processing
              - label: notes
                properties:
                  display: Additional note(s)
                  type: textarea
                  description: Additional notes on why this decision has been made are to be added to the audit trail.
    
      - name: Display Outputs
        shell: bash
        run: |
          echo "Display Outputs"
          echo -e "\n==============================\n"
          echo "Detected Outputs: ${{join(steps.interactive-inputs.outputs.*, '\n')}}"
          echo -e "\n==============================\n"
    
      - name: List the uploaded files in the directory
        shell: bash
        run: |
          echo "Display uploaded files"
          echo -e "\n==============================\n"
          ls -la ${{ steps.interactive-inputs.outputs.requested-files }} # Use the label of the multifile/file field as the key to get the uploaded file directory
          echo -e "\n==============================\n"