actions / runner

The Runner for GitHub Actions :rocket:
https://github.com/features/actions
MIT License
4.82k stars 946 forks source link

Cannot pass dynamic environment from input #3307

Open lamhktommy opened 4 months ago

lamhktommy commented 4 months ago

Describe the bug Reusable workflow cannot get inputs passed from a main workflow

To Reproduce Steps to reproduce the behavior:

dev/action.yml

name: Reusable workflow
on:
  workflow_dispatch:
    inputs:
      source-environment:
        required: true
        type: string
  workflow_call:
    inputs:
      source-environment:
        required: true
        type: string
jobs:
  build-and-push:
    name: Build and Push
    runs-on: ubuntu-latest
    environment: 
      name: ${{ inputs.source-environment }}
    secrets: inherit
    steps:
      - run: echo "${{ inputs.source-environment }}"
        shell: bash

_mainworkflow.yml

jobs:
  action-dev:
    if: github.ref == 'refs/heads/main'
    environment: develop
    name: Deploy to Dev
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Reuse action
        uses: ./.github/actions/dev
        with:
          source-environment: develop

I have tried to use github.event.inputs.source-environment as well and also doesn't work

Expected behavior Expect develop is output in the console

Runner Version and Platform

ubuntu-latest

What's not working?

Unrecognized named-value: 'inputs' image