canonical / action-build

A Github action for building Snapcraft projects
MIT License
42 stars 22 forks source link

[Bug] Environment variable in action-build #41

Open talregev opened 2 years ago

talregev commented 2 years ago

Environment variable in action-build. I want to be able to pass environment variable that I define in workflow. like secrets or other environment variable that define in:

env:
 ENV1: value1

jobs:
  create-snap:
    name: Create snap
    runs-on: ubuntu-latest
    steps:
      - name: Checkout source
        uses: actions/checkout@v3
      - name: Build snap
        uses: snapcore/action-build@v1
        env:
           ENV2: value2

I want to be able to access both envs.

Currently I cannot do it. It not take these envs. Can you make it happen?

sergiusens commented 2 years ago

the env will apply to the runner, but snapcraft creates its own container depending on the base to execute the parts lifecycle

talregev commented 2 years ago

How I can insert the environment variable inside?

talregev commented 2 years ago

https://stackoverflow.com/questions/52297348/lxc-environment-variables

jhenstridge commented 1 year ago

This is more of a Snapcraft problem that an issue with the action itself. Snapcraft aims to run the build in a controlled environment, so it doesn't pass through environment variables to the build (which might not make sense within the container anyway).

With that said, you're free to do whatever you want in your workflow between calling actions/checkout and snapcore/action-build. You could modify the snapcraft.yaml file to edit in your secret. Or you could write it to a file (that will be exposed to the container along with the rest of your project), and check for it there.