Skip to content

bug: environment variables not propagated from env context with shell: cpa.sh {0} #145

Description

@iamazeem

Release: https://github.com/cross-platform-actions/action/tree/v1.1.0/

Previously, something like this was working fine:

    - name: Set up and build
      uses: cross-platform-actions/action@v1.1.0
      env:
        CC: gcc13
      with:
        operating_system: freebsd
        version: '13.2'
        environment_variables: CC
        shell: sh
        run: |
          echo "CC: $CC"

But, now with v1.1.0 and shell: cpa.sh {0}, this doesn't work anymore:

    - name: Set up FreeBSD
      uses: cross-platform-actions/action@v1.1.0
      env:
        CC: gcc13
      with:
        operating_system: freebsd
        version: '13.2'
        environment_variables: CC
        shell: sh

    - name: Build
      shell: cpa.sh {0}
      run: |
        echo "CC: $CC"     ## CC is not available here

Also, with shell: cpa.sh {0}, the env context from the step itself is also not being propagated:

    - name: Set up FreeBSD
      uses: cross-platform-actions/action@v1.1.0
      env:
        CC: gcc13
      with:
        operating_system: freebsd
        version: '13.2'
        # environment_variables: CC    ## commented (works if uncommented)
        shell: sh

    - name: Build
      env:
        CC: gcc13
      shell: cpa.sh {0}
      run: |
        echo "CC: $CC"     ## CC is not available here

For above, it would be great if the env context is automatically propagated to cpa.sh without mentioning in environment_variables.


Solution

Leverage env command from cpa.sh to filter and propagate specific env vars.

Proposed Solution 1: via --env-vars '<space-separated-list>' option

shell: cpa.sh {0} --env-vars "VAR_1 VAR_2 MY_VAR_* VAR_*_TEST_*"

Already implemented and demonstrated in #146.

Proposed Solution 2: via CPA_ENV_VARS env var

shell: cpa.sh {0}
env:
  CPA_ENV_VARS: >-
    VAR_1
    VAR_2
    MY_VAR_*
    VAR_*_TEST_*

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions