-
Notifications
You must be signed in to change notification settings - Fork 16
fix: Make action paths compatible with both GitHub-hosted and self-hosted runners #76
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR enhances the accessibility-scanner action to work on both GitHub-hosted and self-hosted runners by replacing hardcoded runner paths with dynamic path resolution and switching from rsync to cp for better compatibility.
Key Changes:
- Dynamically determines the runner's work directory using
GITHUB_WORKSPACE/../..instead of hardcoding/home/runner/work - Replaces
rsyncwithcp -afor file copying operations to support runners without rsync installed - Updates all action path references to include the full organization/repository path (
github/accessibility-scanner) for consistency
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| action.yml | Updates the top-level action to use portable path resolution and includes the repository name in the action directory structure |
| .github/actions/gh-cache/cache/action.yml | Updates the nested cache action with the same portable path resolution and action reference updates |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ACTION_DIR="${RUNNER_WORK_DIR}/_actions/github/accessibility-scanner/current" | ||
| mkdir -p "${ACTION_DIR}/.github/actions" | ||
| if [ "$(realpath "../../../../.github/actions")" != "$(realpath "${ACTION_DIR}/.github/actions")" ]; then | ||
| cp -a "../../../../.github/actions/." "${ACTION_DIR}/.github/actions/" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@smockle just checking since I hadn't seen -a before (manpages say "Preserves structure and attributes of files but not directory structure"), is this intentional vs using something like -r to recursively copy everything?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great question! cp -a includes -R; from https://www.gnu.org/software/coreutils/manual/html_node/cp-invocation.html#index-_002da-7:
…Equivalent to
-dR --preserve=allwith the reduced diagnostics.
If you’re familiar with rsync, rsync -a (archive) is similar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah oops, there we go -- misremembered the flag as lowercase -r!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
POSIX cp only supports -R: https://pubs.opengroup.org/onlinepubs/9799919799/utilities/cp.html
GNU cp supports -R and -r: https://www.gnu.org/software/coreutils/manual/html_node/cp-invocation.html#index-_002dR-3
The latter doc explains the difference:
It is not portable to use
-rto copy symbolic links or special files. On some non-GNU systems,-rimplies the equivalent of-Land--copy-contentsfor historical reasons. Also, it is not portable to use-Rto copy symbolic links unless you also specify-P, as POSIX allows implementations that dereference symbolic links by default.
Those differences aren’t enormously significant in our case: This repo doesn’t include symbolic links, and the ubuntu-latest runner’s cp supports both -R and -r. Regardless, our command (cp -a) is portable, because -a includes -d, and -d includes --no-dereference (aka -P).
Follow-up to #59 (which explains why copy steps and relative paths are used)
Fixes #71
Instead of assuming actions can be copied to
/home/runner/work(a path which does not exist on some self-hosted runners), this PR uses$GITHUB_WORKSPACE/../..(i.e. the directory above the workflow’s repo and owner directories, aka$RUNNER_TEMP/..). That is/home/runner/workon GitHub-hosted runners, but it might be/actions-runner/_workor/home/runner/_work(etc.) on self-hosted runners.Additionally, this PR uses
cpin place ofrsync, since the latter is not installed on some self-hosted runners. It adds anrsync-like guard to avoid (errors due to) copying a file over itself.I tested this branch’s:
gh-cache/*actions on a self-hosted runner: https://github.com/github/accessibility-sandbox/actions/runs/19863906871 (Hubber access only)gh-cache/*actions on a GitHub-hosted runner: https://github.com/github/accessibility-sandbox/actions/runs/19863535680 (Hubber access only)