actions / upload-artifact

MIT License
3.12k stars 702 forks source link

Action doesn't seem to read environment variables inside a container #216

Open Dwosky opened 3 years ago

Dwosky commented 3 years ago

Describe the bug When calling the action inside a container with container.env variables, the action doesn't seem to be able to use them.

Version

Environment

Screenshots This is the output of the action, where it only gets the global env variables: image

Run/Repo Url The repo is private.

How to reproduce This is a snippet of how the action its configured:

name: Android workflow
on: [push]
env:
  FASTLANE_USER: ${{ secrets.FASTLANE_USER }}
  FASTLANE_PASSWORD: ${{ secrets.FASTLANE_PASSWORD }}
  MATCH_ENTERPRISE_PASSWORD: ${{ secrets.MATCH_ENTERPRISE_PASSWORD }}
  CIRCLE_BUILD_NUM: 10
jobs:
  build:
    name: Build
    environment: some_env
    runs-on: ubuntu-latest
    container:
      image: circleci/android:api-29-ndk
      env:
        API_URL: <some var>
        NODE_ENV: <some var>
        APP_NAME: <some var>
    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      [... Build app ...]
      - name: Save artifact
        uses: actions/upload-artifact@v2
        with:
          name: android-${{ env.APP_NAME }}-${{ env.NODE_ENV }}
          path: android/app/build/outputs/bundle/release/app-release.apk
          retention-days: 2

The action its able to read the variables from env, but not the ones from jobs[*].container.env, so the variables inside the upload-artifact name don't get resolved and name ends in just a plain android--

vasek0001 commented 3 years ago

Describe the bug When calling the action inside a container with container.env variables, the action doesn't seem to be able to use them.

Version

  • [x] V1
  • [ ] V2

Environment

  • [x] self-hosted
  • [ ] Linux
  • [ ] Windows
  • [ ] Mac

Screenshots This is the output of the action, where it only gets the global env variables: image

Run/Repo Url The repo is private.

How to reproduce This is a snippet of how the action its configured:

name: Android workflow
on: [push]
env:
  FASTLANE_USER: ${{ secrets.FASTLANE_USER }}
  FASTLANE_PASSWORD: ${{ secrets.FASTLANE_PASSWORD }}
  MATCH_ENTERPRISE_PASSWORD: ${{ secrets.MATCH_ENTERPRISE_PASSWORD }}
  CIRCLE_BUILD_NUM: 10
jobs:
  build:
    name: Build
    environment: some_env
    runs-on: ubuntu-latest
    container:
      image: circleci/android:api-29-ndk
      env:
        API_URL: <some var>
        NODE_ENV: <some var>
        APP_NAME: <some var>
    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      [... Build app ...]
      - name: Save artifact
        uses: actions/upload-artifact@v2
        with:
          name: android-${{ env.APP_NAME }}-${{ env.NODE_ENV }}
          path: android/app/build/outputs/bundle/release/app-release.apk
          retention-days: 2

The action its able to read the variables from env, but not the ones from jobs[*].container.env, so the variables inside the upload-artifact name don't get resolved and name ends in just a plain android--

amantur commented 2 years ago

We tried to use ${{ env.GITHUB_JOB }} and it did not work but ${{ github.sha }} worked for us.