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

Environment Variables not passed through #84

Closed
tstackhouse opened this issue Aug 2, 2022 · 5 comments
Closed

Environment Variables not passed through #84

tstackhouse opened this issue Aug 2, 2022 · 5 comments
Assignees

Comments

@tstackhouse
Copy link

Describe the bug
Environment variables set on the workflow step (via the env keyword) are not passed through to the command when the workflow runs.

From my workflow:

- name: Destroy Infrastructure
  id: retry_on_error
  uses: nick-fields/retry@v2
  env:
    ENVIRONMENT: dev
    NODE_OPTIONS: '--max_old_space_size=7168'
  with:
    timeout_minutes: 60
    max_attempts: 3
    retry_wait_seconds: 60
    retry_on: error
    command: npx nx destroy ${{matrix.project}} --stage=${{ steps.git-branch.outputs.name }}

Expected behavior
Environment Variables set on the workflow step are used when invoking the command, which is the standard behaviour for the default run action, that this is meant to be a drop-in replacement for.

Screenshots
N/A

Logs
I can gather logs if necessary, but I feel like this is part feature request part bug report, so I'm not sure how useful logs would be.

@tstackhouse
Copy link
Author

I'm continuing to research my issue, and I'm half wondering if it's connected with #76, as I've tried moving my environment variables inline with my command, as well as looking into the NodeJS docs, which indicates that child_process.exec should inherit from process.env if env is not provided as part of the options when called. I didn't think it was related to the SIGPIPE indicated in that issue because my command was editing with Code 1 and Signal null according to the debug log.

@nick-fields
Copy link
Owner

nick-fields commented Aug 4, 2022

I'm continuing to research my issue, and I'm half wondering if it's connected with #76, as I've tried moving my environment variables inline with my command, as well as looking into the NodeJS docs, which indicates that child_process.exec should inherit from process.env if env is not provided as part of the options when called. I didn't think it was related to the SIGPIPE indicated in that issue because my command was editing with Code 1 and Signal null according to the debug log.

Thanks for the research on this, I'm looking into it now

@nick-fields
Copy link
Owner

nick-fields commented Aug 4, 2022

Just published v2.8.0 that I think should resolve this. Thanks for your issue and research!

Can you confirm whether this resolves your issue?

@tstackhouse
Copy link
Author

I had to explicitly make my reference nick-fields/[email protected], but it looks like that did the trick! Thanks for looking into this so quickly, and I'm glad my research was helpful! ❤️

@Norfeldt
Copy link

I tried the following

jobs:
  jest:
    runs-on: ubuntu-latest
    env:
      NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
      MAX_ATTEMPTS: 5
      CI: true
    steps:
      - name: checkout repository
        uses: actions/checkout@v3
      - name: get yarn cache directory path
        id: yarn-cache
        run: echo "::set-output name=dir::$(yarn cache dir)"
      - name: Setup cache key and directory for node_modules cache
        uses: actions/cache@v3
        with:
          path: ${{ steps.yarn-cache.outputs.dir }}
          key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
      - name: yarn
        run: yarn --frozen-lockfile
      - name: jest
        uses: nick-fields/[email protected]
        with:
          command: yarn test --ci --bail --coverage=true
          max_attempts: $MAX_ATTEMPTS
          timeout_minutes: 10

That did not work. But using github secret ${{ secrets.MAX_ATTEMPTS }} worked - but it seems a bit silly to use secrets for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants