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

[BUG] The action doesn't override existing env variable when it is called second time through a separate action. #350

Closed
lurbanski-equinix opened this issue Jul 26, 2022 · 2 comments · Fixed by #453
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@lurbanski-equinix
Copy link

lurbanski-equinix commented Jul 26, 2022

Describe the bug

  1. A job triggers an action X which call the vault-action.
  2. New env variable Y is set and has value VALUE1.
  3. Job triggers the action X again where the vault-action is called in order to set the X var with different value e.g. VALUE2.
  4. Bug - in the action X the Y var has still the value VALUE1.
  5. In a next step of job there is correct value VALUE2

To Reproduce
The yaml of the vault-action step, with any sensitive information masked or removed.

#job.yaml
name: Test workflow
on:
  workflow_dispatch:

jobs:
  Use_vault_throught_the_same_action_twice_using_hashicorp_vault:
    runs-on: [ REMOVED ]
    steps:
      - name: Log github context
        env:
          GITHUB_CONTEXT: ${{ toJson(github) }}
        run: |
          echo "$GITHUB_CONTEXT"

      - name: Checkout source code
        uses: actions/checkout@v2

      - uses: ./.github/actions/lurbanski-hashicorp-action
        with:
          var: lurbanski1

      - uses: ./.github/actions/lurbanski-hashicorp-action
        with:
          var: lurbanski2

      - name: Show LURBANSKI_TEST
        run: |
          var=${{ env.LURBANSKI_TEST }}
          echo ${var:0:1}UUU${var:1}
#lurbanski-hashicorp-action/action.yaml
name: lurbanski-hashicorp-action
description: lurbanski-hashicorp-action
inputs:
  var:
    description: lurbanski1, lurbanski2
    required: true

runs:
  using: composite
  steps:
    - name: Download LURBANSKI_TEST1_KEY
      if: ${{ inputs.var == 'lurbanski1' }}
      uses: hashicorp/[email protected]
      with:
        url: REMOVED
        namespace: REMOVED
        method: kubernetes
        role: REMOVED
        path: REMOVED
        secrets: |
          REMOVED LURBANSKI_TEST1_KEY | LURBANSKI_TEST

    - name: Download LURBANSKI_TEST2_KEY
      if: ${{ inputs.var == 'lurbanski2' }}
      uses: hashicorp/[email protected]
      with:
        url: REMOVED
        namespace: REMOVED
        method: kubernetes
        role: REMOVED
        path: REMOVED
        secrets: |
          REMOVED LURBANSKI_TEST2_KEY | LURBANSKI_TEST

    - name: Show LURBANSKI_TEST
      run: |
        var=${{ env.LURBANSKI_TEST }}
        echo ${var:0:1}UUU${var:1}
      shell: bash

**Expected behavior**
The X action should see the Y variable with a new value when it is called second time.

**Log Output**
<img width="862" alt="image" src="https://user-images.githubusercontent.com/89976258/180954201-66fb3bc2-0d7e-4aa3-af0e-0cfbc1bcec60.png">
@lurbanski-equinix lurbanski-equinix added the bug Something isn't working label Jul 26, 2022
@swenson swenson added the good first issue Good for newcomers label Aug 9, 2022
@leonardovillela
Copy link
Contributor

I believe this bug is now fixed. I was thinking about working on this issue, so today I tried to reproduce it by writing an E2E test that was expected to fail but the test passed. You can check the E2E test here and the Actions run result is here.

My questioning now is if this bug was fixed intentionally and thus we have a test written to ensure this bug does not become a regression in the future. If not, maybe I can submit a PR with my E2E test changes 💭

What do you think @swenson?

@Zlaticanin
Copy link

Hello @leonardovillela, thank you for working on the issue. Looking through changes made to our E2E tests, I don't see anything that would address this intentionally. Your contribution would be appreciated and we encourage you to submit a PR with your E2E test changes. Thank you for your effort and for bringing this to our attention! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants