SpicyPizza / create-envfile

Github Action to create a .env file with Github Secrets
MIT License
423 stars 73 forks source link

Absolute path issue #43

Open AngelOnFira opened 2 years ago

AngelOnFira commented 2 years ago

I am facing issue while creating .env file image Traceback (most recent call last): File "/opt/action/create-envfile.py", line 38, in raise Exception("Absolute paths are not allowed. Please use a relative path.") Exception: Absolute paths are not allowed. Please use a relative path. Please help to resolvee the issue @AngelOnFira

Originally posted by @ZinatSayyad in https://github.com/SpicyPizza/create-envfile/issues/10#issuecomment-1041457301

AngelOnFira commented 2 years ago

@ZinatSayyad what is the path you're using for the directory of the env file?

ZinatSayyad commented 2 years ago

@ZinatSayyad what is the path you're using for the directory of the env file?

name: devlopment-deployment

Controls when the workflow will run

on:

Triggers the workflow on push or pull request events but only for the dev branch

push: branches: [development,master] pull_request: branches: [development,master]

Allows you to run this workflow manually from the Actions tab

workflow_dispatch: inputs: brand: description: 'Define brand name' required: true country: description: 'Define brand Country' required: true locale: description: 'Define brand locale' required: true default: 'default'

A workflow run is made up of one or more jobs that can run sequentially or in parallel

jobs: printInputs: runs-on: ubuntu-latest steps:

this is my yml file

ZinatSayyad commented 2 years ago

@AngelOnFira there are two different error I am facing ,For build that is triggered automatically when we push the code on git showing this error image and the build that I triggered manually is showing this error image

AngelOnFira commented 2 years ago

So the absolute path error should only occur if the directory environment variable starts with a slash /.

if directory == "":
    full_path = os.path.join(path, file_name)
elif directory.startswith("/"):
    # Throw an error saying that absolute paths are not allowed. This is because
    # we're in a Docker container, and an absolute path would lead us out of the
    # mounted directory.
    raise Exception("Absolute paths are not allowed. Please use a relative path.")

I'm unsure why it would be failing for you, since it seems that you aren't setting that variable. Can you verify that the environment variable INPUT_DIRECTORY isn't being set by something else?

As for the second problem, that error is occurring because your AWS_CLIENTID is an empty string. In #42 we are discussing a flag to allow this, maybe check that out too?

mfisco commented 2 years ago

I was having the same issue when I upgraded from v1.2 to v1.3.1 and was able to get it working by simply changing the directory path like so:

       ...
      - name: Create .env file
        uses: SpicyPizza/create-envfile@v1.3.1
        with:
          ...
        # directory: ${{ github.workspace }}/src    # <---- Worked with v1.2, but not v1.3.1
          directory: src                            # <---- Works with v1.3.1
Wadprog commented 2 years ago

Has anyone encountered a solution for this issue?

AngelOnFira commented 1 year ago

We might be able to do absolute paths now that we're no longer in the container. I might look back into this.