Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

with context with field names containing '-' create POSIX-uncompliant variables #219

Closed
dmadisetti opened this issue Nov 14, 2019 · 1 comment
Labels
bug Something isn't working

Comments

@dmadisetti
Copy link

dmadisetti commented Nov 14, 2019

Describe the bug
Environmental variables provided to a docker action through with that contain a '-' are not easily accessible, and are moreover not POSIX-compliant

To Reproduce
Consider

name: Docker Image CI
on: [push]
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@master
    - name: Run Bazel unit tests.
      uses: dmadisetti/bazel-action/1.1.0@test # or any docker endpoint
      with:
        working-directory: ./src # Problematic field
        entrypoint: env
        other: other # Just another for reference

We note that the docker command invoked is something like

/usr/bin/docker run --name e4e3a71d2cda2576d484cb8eef9019d724e5d_93f69a --label 2e4e3a --workdir /github/workspace --rm -e INPUT_WORKING-DIRECTORY -e INPUT_OTHER -e HOME -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e GITHUB_ACTIONS=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/dir/dir":"/github/workspace" 2e4e3a:71d2cda2576d484cb8eef9019d724e5d test //dir:all

and env as expected is something like

...
INPUT_WORKING-DIRECTORY=./src
...

Here's a stack exchange on why this isn't good: https://stackoverflow.com/questions/36989263/why-cant-environment-variables-with-dashes-be-accessed-in-bash-4-1-2

Expected behavior
It would be nice if you provided a warning that a bad variable was supplied to the environment, OR sub '-' with '_' (this would be much more preferable)

Additional context
You can potentially grep env to capture this variable in bash. Note that sh drops the variable all together. I think this is potentially a design choice on your part. Functionality is as expected but requires a work around to be viable.

@dmadisetti dmadisetti added the bug Something isn't working label Nov 14, 2019
dmadisetti added a commit to AnotherGroupChat/toolkit that referenced this issue Nov 14, 2019
As per actions#219, variable names with a `-` are not POSIX-Compliant
@bryanmacfarlane
Copy link
Member

Can you create an issue on github community? I think the suggestion would be good for the runner but it doesn't seem to be a toolkit issue.

zmughal added a commit to PDLPorters/devops that referenced this issue Aug 31, 2021
Apparently GitHub Actions uses non-POSIX compliant environment variable
names (!!!) for INPUT_* variables.

See <https://github.community/t/dashes-in-docker-action-inputs-produce-unreadable-env-vars/117382/7>,
<actions/toolkit#219>.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants