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

unable to pass GITHUB_REF var as input #5

Open
richkifvel opened this issue Sep 17, 2021 · 1 comment
Open

unable to pass GITHUB_REF var as input #5

richkifvel opened this issue Sep 17, 2021 · 1 comment

Comments

@richkifvel
Copy link

richkifvel commented Sep 17, 2021

Hi,

No matter which way I try I don't seem to be able to get the branch name from the default env var $GITHuB_REF to be read properly by the input variable.

The format I need to pass in is refs/head/branch-name

My Github Action as of my latest try is laid out as:

jobs:
  terraform:
    name: "Terraform"
    runs-on: ubuntu-latest
    env: 
      input: $GITHUB_REF
    
    steps:
      - name: Checkout
        uses: actions/[email protected]
        with:
          ref: ${{ github.head_ref }}
          token: ${{ secrets.CROSS_REPO_TOKEN }}
            
      - name: create json
        uses: schdck/create-env-json@v2
        id: create-env
        with:
          file-name: 'envs.json'
          dev: name
          branch: ${{ env.input }}  ------> problem variable which can't read a variable 
          queue: plan

      - name: create json var
        shell: bash
        run: |
          echo "branch = ${{ env.input }}"
          cat | tr '[:upper:]' '[:lower:]' < ${{ steps.create-env.outputs.full-path }} 
          FILE=$(cat | tr '[:upper:]' '[:lower:]' <  ${{ steps.create-env.outputs.full-path }})
          echo JSON=$FILE >> $GITHUB_ENV

I setup cat to check the json file which produces the following results:

The above code results in: {"DEV":"name","BRANCH":"$GITHUB_REF","QUEUE":"plan"}

What I've tried otherwise is referencing the default env var directly:
branch: $GITHUB_REF results in nothing being passed eg branch: {"DEV":"name","BRANCH":"","QUEUE":"plan"}

I am additionally echoing the variable so check the variable string and this returns the branch name as expected. Any idea as to why the create-env-json action cannot read the variables?

Thanks,

@cluuu
Copy link

cluuu commented Nov 10, 2022

@richkifvel I am currently facing the same issue. Did you find a solution for 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

2 participants