Github.workspace on forked repositories

I’m trying to understand why on a forked repository the ${{ github.workspace }} variable resolves to the parent repository. Is this intende bahaviour? I’m not sure why things are going wrong for me but I did notice this variable not aligning with my repository name. It makes more sense to me that we’d have our own unique workspace. I’ve got a more detailed explanation of my scenario at Github Actions variables point to fork parent - Stack Overflow

The workspace context variable refers to the default working directory used by GitHub Actions. The workspace variable is not intended to be a representation of the repository, nor does it relate to any specific repository, it’s just a directory: in principle, it could be a random string.

  1. A new runner instance is created with a fresh filesystem
  2. A new, unique workspace is created, the name of which is available in ${{ github.workspace }}
  3. The Workflow may now create files in that Workspace

The workspace variable is only usually relevant if you need to interact with the Workspace using an absolute path, or if you need to change the working directory. If you’re only interacting with relative paths in the default working directory then you are unlikely to ever need the github.workspace value.

For example, rather than use an absolute path involving the GitHub Workspace, you can use a relative path:

- name: Zip the release
  uses: papeloto/action-zip@v1
    files: LICENSE *.dll nfive.yml nfive.lock fxmanifest.lua index.html config/
- name: Attach Zip as build artifact
  uses: actions/upload-artifact@v1
    name: nfive

Ok thanks, rather than first I went with this instead:

    - name: Move files to artifact folder
      shell: pwsh
      run: |
        mkdir Build        
        Move-Item -Path,LICENSE,*.dll,nfive.yml,nfive.lock,fxmanifest.lua,index.html,config -Destination Build
    - name: Attach Zip as build artifact
      uses: actions/upload-artifact@v1
        name: nfive
        path: Build

otherwise I ended up with a zip inside a zip. Also that zip step always gives me an empty zip file. Don’t know if it’s because it’s windows-latest. If you know of a zip action that works on windows I’d be grateful as I need it for another project where I want to zip a WPF .NET 5.0 desktop app and attach that zip to a CreateRelease action. I have everything setup but always get an empty zip file.

Thanks heaps, I’d been going in circles for awhile and got a little lost I think with it constantly failing to build.