Skip to content

Conversation

@smockle
Copy link
Collaborator

@smockle smockle commented Dec 2, 2025

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/work on GitHub-hosted runners, but it might be /actions-runner/_work or /home/runner/_work (etc.) on self-hosted runners.

Additionally, this PR uses cp in place of rsync, since the latter is not installed on some self-hosted runners. It adds an rsync-like guard to avoid (errors due to) copying a file over itself.

I tested this branch’s:

Copy link
Contributor

Copilot AI left a 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 rsync with cp -a for 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/"
Copy link

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?

Copy link
Collaborator Author

@smockle smockle Dec 3, 2025

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=all with the reduced diagnostics.

If you’re familiar with rsync, rsync -a (archive) is similar.

Copy link

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!

Copy link
Collaborator Author

@smockle smockle Dec 3, 2025

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 -r to copy symbolic links or special files. On some non-GNU systems, -r implies the equivalent of -L and --copy-contents for historical reasons. Also, it is not portable to use -R to 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).

@smockle smockle requested a review from JoyceZhu December 3, 2025 00:56
@smockle smockle merged commit a473a51 into main Dec 3, 2025
11 checks passed
@smockle smockle deleted the smockle/self-hosted-runners branch December 3, 2025 04:58
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

Successfully merging this pull request may close these issues.

Action is not compatible with self-hosted runners

3 participants