nektos / act

Run your GitHub Actions locally 🚀

Home Page:https://nektosact.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

If using workflow_call and matrix inputs are not being taken in consideration by second workflow

maonat opened this issue · comments

Bug report info

act version:            0.2.59
GOOS:                   darwin
GOARCH:                 arm64
NumCPU:                 12
Docker host:            unix:///Users/username/.colima/default/docker.sock
Sockets found:
        /var/run/docker.sock
        $HOME/.colima/docker.sock
        $HOME/.docker/run/docker.sock
Config files:           
        /Users/username/.actrc:
                -P ubuntu-latest=catthehacker/ubuntu:full-latest
                -P ubuntu-latest=catthehacker/ubuntu:full-20.04
                -P ubuntu-18.04=catthehacker/ubuntu:full-18.04
Build info:
        Go version:            go1.21.6
        Module path:           command-line-arguments
        Main version:          
        Main path:             
        Main checksum:         
        Build settings:
                -buildmode:           exe
                -compiler:            gc
                -ldflags:             -X main.version=0.2.59
                DefaultGODEBUG:       panicnil=1
                CGO_ENABLED:          1
                CGO_CFLAGS:           
                CGO_CPPFLAGS:         
                CGO_CXXFLAGS:         
                CGO_LDFLAGS:          
                GOARCH:               arm64
                GOOS:                 darwin
Docker Engine:
        Engine version:        24.0.7
        Engine runtime:        runc
        Cgroup version:        2
        Cgroup driver:         cgroupfs
        Storage driver:        overlay2
        Registry URI:          https://index.docker.io/v1/
        OS:                    Ubuntu 23.10
        OS type:               linux
        OS version:            23.10
        OS arch:               aarch64
        OS kernel:             6.5.0-17-generic
        OS CPU:                4
        OS memory:             7922 MB
        Security options:
                name=apparmor
                name=seccomp,profile=builtin
                name=cgroupns

Command used with act

act -v workflow_dispatch -P self-hosted=my_acr/my_image:latest -p=false -W .github/workflows/cron-check-environment.yml --container-daemon-socket '/Users/username/.colima/default/docker.sock' --container-architecture linux/amd64 --secret-file secrets.yml

Describe issue

When launching origin workflow, the other workflow called with workflow_dispatch detect the provided inputs (passed on the "with" key) but if inputs.value is being called within the child workflow, they're empty.

Link to GitHub repository

No response

Parent Workflow content

name: Cron shutdown environments

on:
  # schedule:
  #   - cron: '0 * * * MON-FRI' # Every hour at minute 0 from Monday to Friday - UTC
  workflow_dispatch:

jobs:
  preparation:
    runs-on: self-hosted
    outputs:
      env_to_start: ${{ steps.environment_list_population.outputs.env_to_start }}
      env_to_stop: ${{ steps.environment_list_population.outputs.env_to_stop }}
    
    steps:
      - name: Get all environments to execute
        id: environment_list_population
        run: |
          ENV_TO_STOP=";myenv1"
          # Preparing outputs
          ENV_TO_STOP=$(echo -n $ENV_TO_STOP | jq -R -s -c 'split(";") | map(select(length > 0))')
          echo "env_to_stop=$ENV_TO_STOP" >> $GITHUB_OUTPUT

  shutdown-environment:
    needs: preparation
    strategy:
      matrix:
        environment: ${{ fromJson(needs.preparation.outputs.env_to_stop) }}
      max-parallel: 10
    uses: ./.github/workflows/shutdown-environment.yml
    if: ${{ needs.preparation.outputs.env_to_stop != '[]' }}
    with:
      environment: ${{ matrix.environment }}
      title: ${{ matrix.environment }} - Automated Shutdown trigger by CRON

Child Workflow content

name: Shutdown environment
run-name: |
  ${{ inputs.title != '' && inputs.title || format('{0} {1}', inputs.environment, '- Manual Shutdown') }} by @${{ github.actor }}

on:
  workflow_call:
    inputs:
      environment:
        description: The environment that we want shutdown
        type: string
        required: true
      title:
        description: A custom title that can be used for this workflow run
        type: string
        required: false
      env-path:
        description: Path to the files where the environments files are located in the repository
        type: string
        required: false
  workflow_dispatch:
    inputs:
      environment:
        description: The environment that we want shutdown
        type: string
        required: true
      title:
        description: A custom title that can be used for this workflow run
        type: string
        required: false
      env-path:
        description: Path to the files where the environments files are located in the repository
        type: string
        required: false
        default: environments

env:
  ENV_PATH: ${{ github.event.inputs.env-path || 'environments' }}

jobs:
  preparation:
    runs-on: self-hosted

    steps:
      - name: 'Checkout'
        uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - name: Check if environment secret file exists
        id: environment_secrets_exists
        run: |
          set -x
          echo "${{ inputs.title }}"
          ENV_NAME=$(echo ${{ inputs.environment }} | tr '[[:upper:]]' '[[:lower:]]')
          export ENV_FILE=${ENV_PATH}/${ENV_NAME}.yml
          if [[ ! -f $ENV_FILE ]]; then
            echo "Environment file does not exists in the environments directory! Exiting execution."
            exit 2
          fi

Relevant log output

[shutdown-environment/Shutdown environment/preparation] [DEBUG] expression '${{ matrix.environment }}' rewritten to 'format('{0}', matrix.environment)'
[shutdown-environment/Shutdown environment/preparation] [DEBUG] evaluating expression 'format('{0}', matrix.environment)'
[shutdown-environment/Shutdown environment/preparation] [DEBUG] expression 'format('{0}', matrix.environment)' evaluated to '%!t(string=myenv1)'
[shutdown-environment/Shutdown environment/preparation] [DEBUG] expression '${{ matrix.environment }} - Automated Shutdown trigger by CRON' rewritten to 'format('{0} - Automated Shutdown trigger by CRON', matrix.environment)'
[shutdown-environment/Shutdown environment/preparation] [DEBUG] evaluating expression 'format('{0} - Automated Shutdown trigger by CRON', matrix.environment)'
[shutdown-environment/Shutdown environment/preparation] [DEBUG] expression 'format('{0} - Automated Shutdown trigger by CRON', matrix.environment)' evaluated to '%!t(string=myenv1 - Automated Shutdown trigger by CRON)'
[shutdown-environment/Shutdown environment/preparation] [DEBUG] Loading revision from git directory
[shutdown-environment/Shutdown environment/preparation] [DEBUG] HEAD points to 'revision_id'
[shutdown-environment/Shutdown environment/preparation] [DEBUG] using github ref: refs/heads/main
[shutdown-environment/Shutdown environment/preparation] [DEBUG] expression 'set -x
echo "${{ inputs.title }}"
ENV_NAME=$(echo ${{ inputs.environment }} | tr '[[:upper:]]' '[[:lower:]]')
export ENV_FILE=${ENV_PATH}/${ENV_NAME}.yml
if [[ ! -f $ENV_FILE ]]; then
  echo "Environment file does not exists in the environments directory! Exiting execution."
  exit 2
fi' rewritten to 'format('set -x
echo "{0}"
ENV_NAME=$(echo {1} | tr ''[[:upper:]]'' ''[[:lower:]]'')
export ENV_FILE=${{ENV_PATH}}/${{ENV_NAME}}.yml
if [[ ! -f $ENV_FILE ]]; then
  echo "Environment file does not exists in the environments directory! Exiting execution."
  exit 2
fi', inputs.title, inputs.environment)'
[shutdown-environment/Shutdown environment/preparation] [DEBUG] evaluating expression 'format('set -x
echo "{0}"
ENV_NAME=$(echo {1} | tr ''[[:upper:]]'' ''[[:lower:]]'')
export ENV_FILE=${{ENV_PATH}}/${{ENV_NAME}}.yml
if [[ ! -f $ENV_FILE ]]; then
  echo "Environment file does not exists in the environments directory! Exiting execution."
  exit 2
fi', inputs.title, inputs.environment)'
[shutdown-environment/Shutdown environment/preparation] [DEBUG] expression 'format('set -x
echo "{0}"
ENV_NAME=$(echo {1} | tr ''[[:upper:]]'' ''[[:lower:]]'')
export ENV_FILE=${{ENV_PATH}}/${{ENV_NAME}}.yml
if [[ ! -f $ENV_FILE ]]; then
  echo "Environment file does not exists in the environments directory! Exiting execution."
  exit 2
fi', inputs.title, inputs.environment)' evaluated to '%!t(string=set -x
echo ""
ENV_NAME=$(echo  | tr '[[:upper:]]' '[[:lower:]]')
export ENV_FILE=${ENV_PATH}/${ENV_NAME}.yml
if [[ ! -f $ENV_FILE ]]; then
  echo "Environment file does not exists in the environments directory! Exiting execution."
  exit 2
fi)'
[shutdown-environment/Shutdown environment/preparation] [DEBUG] Wrote command 

set -x
echo ""
ENV_NAME=$(echo  | tr '[[:upper:]]' '[[:lower:]]')
export ENV_FILE=${ENV_PATH}/${ENV_NAME}.yml
if [[ ! -f $ENV_FILE ]]; then
  echo "Environment file does not exists in the environments directory! Exiting execution."
  exit 2
fi

 to 'workflow/environment_secrets_exists'
[shutdown-environment/Shutdown environment/preparation] [DEBUG] Writing entry to tarball workflow/environment_secrets_exists len:245
[shutdown-environment/Shutdown environment/preparation] [DEBUG] Extracting content to '/var/run/act'
[shutdown-environment/Shutdown environment/preparation]   🐳  docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/environment_secrets_exists] user= workdir=
[shutdown-environment/Shutdown environment/preparation] [DEBUG] Exec command '[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/environment_secrets_exists]'
[shutdown-environment/Shutdown environment/preparation] [DEBUG] Working directory '/Users/username/repos/ff/repo-name'
DEBU[0000] Saving notices etag=914e4f2c-2a73-4040-afb7-602be630d6dc 
DEBU[0000] No new notices                               
| + echo ''
| 
| ++ echo
| ++ tr '[[:upper:]]' '[[:lower:]]'
| + ENV_NAME=
| + export ENV_FILE=environments/.yml
| + ENV_FILE=environments/.yml
| + [[ ! -f environments/.yml ]]
| + echo 'Environment file does not exists in the environments directory! Exiting execution.'
| Environment file does not exists in the environments directory! Exiting execution.
| + exit 2
[shutdown-environment/Shutdown environment/preparation]   ❌  Failure - Main Check if environment secret file exists
[shutdown-environment/Shutdown environment/preparation] exitcode '2': failure

Additional information

No response

Looks the same as #2046