The GITHUB_WORKSPACE is set with an incorrect directory
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 6.3k
- Forks
- 1.4k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 24
Description
Associated GitHub Community ticket: https://github.community/t/github-actions-is-setting-github-workspace-incorrectly/132187
The customer has a workflow like as below:
name: CI
env:
JAVA_VERSION: 11.0.7
NOW: $(($(date +%s%N)/1000000))
on:
pull_request:
jobs:
evaluate-environment:
name: Look at the environment
runs-on: [self-hosted, humio, special]
steps:
- name: Print github workspace
run: |
echo "GITHUB_WORKSPACE = $GITHUB_WORKSPACE"
echo "github.workspace = ${{ github.workspace }}"
echo "pr.ref = ${{github.event.pull_request.head.ref}}"
echo "github.ref = ${{ github.ref }}"
echo "$GITHUB_CONTEXT"
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
checkout-code:
name: Check out the code and see what ref comes out
runs-on: [self-hosted, humio, special]
steps:
- name: Remove existing git hooks
run: git config --unset core.hooksPath && rm -rf .git/hooks/ || true
- uses: actions/checkout@v2
with:
path: ${{ github.ref }}
clean: true
lfs: true
- name: Checkout LFS
run: git lfs checkout
- name: Print workspace path
run: echo $GITHUB_WORKSPACE && pwd && echo ${{github.ref}}
- name: current checkout
run: git log -10
When viewing the value of 'GITHUB_WORKSPACE' and 'github.workspace' printed in the logs, he found that the path was "/actions-runner/gh-ci-01/_work/humio/refs/pull/8401/merge".
Normally, the path of the default workspace should like as below:
<runner-installation-directory>/_work/<repo-name>/<repo-name>
OR
<runner-installation-directory>/work/<repo-name>/<repo-name>
In the customer's case, the correct path should be "/actions-runner/gh-ci-01/_work/humio/humio". But why the path was changed?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the self-hosted runner workspace handling and reproduce the supplied workflow, comparing GITHUB_WORKSPACE with github.workspace and the checkout path. Check how actions/checkout@v2 behaves with the pull-request ref and path settings; done means identifying why the workspace resolves to the pull-request merge directory and documenting or correcting the expected behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- github-actions, shell, yaml
- Domain
- ci-cd, devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100