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

Feature: add support for path as environment variable #339

Closed
jwillemsen opened this issue Aug 26, 2020 · 3 comments
Closed

Feature: add support for path as environment variable #339

jwillemsen opened this issue Aug 26, 2020 · 3 comments

Comments

@jwillemsen
Copy link

We are using environment variables throughout our scripts to point to the location of the various git repositories we are using. Within our github action we are using for example

env:
  DOC_ROOT: ${{ github.workspace }}/ACE_TAO

When now using checkout we need to pass ACE_TAO as path but it would be more easier for maintenance that we can use $DOC_ROOT, so

    - name: checkout ACE_TAO
      uses: actions/checkout@v2
      with:
        repository: DOCGroup/ACE_TAO
        path: ACE_TAO
        ref: Latest_Micro

to something like below, refer to DOC_ROOT env

    - name: checkout ACE_TAO
      uses: actions/checkout@v2
      with:
        repository: DOCGroup/ACE_TAO
        path: $DOC_ROOT
        ref: Latest_Micro
@jwillemsen jwillemsen changed the title Add support for path as environment variable Feature: add support for path as environment variable Aug 26, 2020
@jwillemsen
Copy link
Author

Ok, this seems to work, so the documentation should be enhanced

name: linux

on:
  push:
  pull_request:

jobs:
  build:
    strategy:
      matrix:
        include:
          - os: ubuntu-18.04
    runs-on: ${{ matrix.os }}
    name: ${{ matrix.os }}
    env:
      DOC_ROOT: ${{ github.workspace }}/FOO/ACE
    steps:
    - name: checkout ACE_TAO
      uses: actions/checkout@v2
      with:
        repository: DOCGroup/ACE_TAO
        path: ${{ env.DOC_ROOT }}
    - name: Check file existence
      id: check_files
      uses: andstor/file-existence-action@v1
      with:
        files: "FOO/ACE/README.md"

@mtazzari
Copy link

mtazzari commented Sep 2, 2022

Thanks for posting the working solution! I was surprised that this was not working:

env:
  BUILD_REPO: owner/repo

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: clone build repository
        uses: actions/checkout@v3
        with:
          repository: $BUILD_REPO

and using "$BUILD_REPO" or ${BUILD_REPO} or any combination didn't work either. I was getting the following error in GH Actions:

Invalid repository '${BUILD_REPO}'. Expected format {owner}/{repo}.

However, using contexts works:

env:
  BUILD_REPO: owner/repo

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: clone build repository
        uses: actions/checkout@v3
        with:
          repository: ${{ env.BUILD_REPO }}

@raidski20
Copy link

@mtazzari

I run into the same situation now, and I can't understand why I must use contexts ${{ env.BUILD_REPO }} instead of typical environment variables $BUILD_REPO?

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

3 participants