Paths and environment variables in artifact paths

Hello,

I am having some issue finding the path to where a checkout happens. I could of course, set an environment variable to the $PWD in a step but then I can’t use that in an artifact path since as far as I understand an artifact path does not expand shell variables.

If I save a file in a step, how can I get that path to the artifact path so that it is saved?

There is a default environment variable named GITHUB_WORKSPACE.

The GitHub workspace directory path. The workspace directory contains a subdirectory with a copy of your repository if your workflow uses the actions/checkout action. If you don’t use the actions/checkout action, the directory will be empty. For example, /home/runner/work/my-repo-name/my-repo-name.

If you don’t set working-directory keyword in your step, the default working directory is /home/runner/work/my-repo-name/my-repo-name.

Let me show you an example, there is my file structure in the repo:

 After checkout action, these folders and files in the root of my repo will exist under /home/runner/work/orgrepo1/orgrepo1

I want to upload contents under projects/frontend folder. Then I use path: ./projects/frontend/ in actions/upload-artifact@v1.0.0.

name: publish artifacts

on: push

jobs:

  build:

    runs-on: ubuntu-latest

    steps:

      - uses: actions/checkout@v1

      - name: Upload artifact

        uses: actions/upload-artifact@v1.0.0

        with:

          # Artifact name

          name: drop1

          # Directory containing files to upload

          path: ./projects/frontend/