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

Absolute path issue #43

Open
AngelOnFira opened this issue Feb 16, 2022 · 7 comments
Open

Absolute path issue #43

AngelOnFira opened this issue Feb 16, 2022 · 7 comments

Comments

@AngelOnFira
Copy link
Member

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 #10 (comment)

@AngelOnFira
Copy link
Member Author

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

@ZinatSayyad
Copy link

@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:
- run: |
echo "Brand: ${{ github.event.inputs.brand }}"
echo "Branch: ${{ github.event.inputs.locale }}"

This workflow contains a single job called "build"

build:
# The type of runner that the job will run on
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set env to staging
if: endsWith(github.ref, '/development')
run: |
echo "ENVIRONMENT=stage" >> $GITHUB_ENV
echo "S3_BUCKET=${{ secrets.AWS_S3_BUCKET_STAGE}}" >> $GITHUB_ENV
echo "CONFIG_URL=${{ secrets.AWS_STAGE_CONFIG_URL }}/${{ github.event.inputs.brand }}/${{ github.event.inputs.locale }}/brand.config.json" >> $GITHUB_ENV
echo "$GITHUB_CONTEXT"

  - name: Set env to production
    if: endsWith(github.ref, '/master')
    run: |
      echo "ENVIRONMENT=prod" >> $GITHUB_ENV
      echo "S3_BUCKET=${{  secrets.AWS_S3_BUCKET_PROD }}" >> $GITHUB_ENV
      echo "CONFIG_URL=${{ secrets.AWS_STAGE_CONFIG_URL }}/${{ github.event.inputs.brand }}/${{ github.event.inputs.locale }}/brand.config.json" >> $GITHUB_ENV


  - name: Make envfile
    uses: SpicyPizza/create-envfile@v1.3
    with:
      envkey_DEBUG: false 
      envkey_NODE_ENV: ${{secrets.NODE_ENV}}
      envkey_AWS_USERPOOLID: ${{ secrets[format('AWS_USERPOOLID_{0}_{1}', github.event.inputs.brand, github.event.inputs.country)] }}
      envkey_AWS_CLIENTID: ${{ secrets[format('AWS_CLIENTID_{0}_{1}', github.event.inputs.brand, github.event.inputs.country)] }}
      envkey_AWS_REGION: ${{secrets.AWS_REGION}}
      envkey_USER_PROFILE_STORE_API_URL: ${{secrets.USER_PROFILE_STORE_API_URL}}
      envkey_OPTIN_API_URL: ${{secrets.OPTIN_API_URL}}
      envkey_X_API_KEY: ${{ secrets[format('X_API_KEY_{0}_{1}', github.event.inputs.brand, github.event.inputs.country)] }}
      file_name: .env

  - name: Show files
    run: |
      ls -a
      ls -a ./packages
      ls -a ./packages/widget-template

  - name: yarn install
    run: yarn install

  - name: Run linting
    run: yarn lint

  - name: Clear dist folder
    run: rm -rf /home/runner/work/login-widget/login-widget/packages/widget-template/dist/

  - name: Run build
    run: yarn build

  - name: Show files
    run: |
      ls -a
      ls -a ./packages
      ls -a ./packages/widget-template/dist
      ls -a ./packages/widget-template/dist/ul-login

  - name: Publish artifacts
    uses: actions/upload-artifact@v2
    with:
      name: dist
      path: /home/runner/work/login-widget/login-widget/packages/widget-template/dist/ul-login/*

  - uses: aws-actions/configure-aws-credentials@v1
    with:
      aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
      aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
      aws-region: ${{ secrets.AWS_REGION }}
  - run: aws s3 rm s3://$S3_BUCKET/${{ github.event.inputs.brand }}/${{ github.event.inputs.locale }} --recursive
  - run: aws s3 sync /home/runner/work/login-widget/login-widget/packages/widget-template/dist/ul-login/ s3://$S3_BUCKET/${{github.event.inputs.brand }}/${{github.event.inputs.locale }} --delete

this is my yml file

@ZinatSayyad
Copy link

@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
Copy link
Member Author

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
Copy link

mfisco commented May 11, 2022

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
Copy link

Wadprog commented Nov 8, 2022

Has anyone encountered a solution for this issue?

@AngelOnFira
Copy link
Member Author

We might be able to do absolute paths now that we're no longer in the container. I might look back into 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