Skip to content

Commit a473a51

Browse files
authored
fix: Make action paths compatible with both GitHub-hosted and self-hosted runners (#76)
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: - Top-level scanner action on a self-hosted runner: https://github.com/github/accessibility-sandbox/actions/runs/19862994002 (Hubber access only) (this run failed, but for reasons unrelated to paths) - Top-level scanner action on a GitHub-hosted runner: https://github.com/github/accessibility-sandbox/actions/runs/19863037045 (Hubber access only) - Nested `gh-cache/*` actions on a self-hosted runner: https://github.com/github/accessibility-sandbox/actions/runs/19863906871 (Hubber access only) - Nested `gh-cache/*` actions on a GitHub-hosted runner: https://github.com/github/accessibility-sandbox/actions/runs/19863535680 (Hubber access only)
2 parents d790d79 + e3611c2 commit a473a51

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

.github/actions/gh-cache/cache/action.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,14 @@ runs:
2828
working-directory: ${{ github.action_path }}
2929
shell: bash
3030
run: |
31-
mkdir -p /home/runner/work/_actions/current/.github/actions
32-
rsync -a ../../../../.github/actions/ /home/runner/work/_actions/current/.github/actions/
33-
ls -ltra /home/runner/work/_actions/current/.github/actions
31+
RUNNER_WORK_DIR="$(realpath "${GITHUB_WORKSPACE}/../..")"
32+
ACTION_DIR="${RUNNER_WORK_DIR}/_actions/github/accessibility-scanner/current"
33+
mkdir -p "${ACTION_DIR}/.github/actions"
34+
if [ "$(realpath "../../../../.github/actions")" != "$(realpath "${ACTION_DIR}/.github/actions")" ]; then
35+
cp -a "../../../../.github/actions/." "${ACTION_DIR}/.github/actions/"
36+
fi
3437
- name: Restore cached value
35-
uses: ./../../_actions/current/.github/actions/gh-cache/restore
38+
uses: ./../../_actions/github/accessibility-scanner/current/.github/actions/gh-cache/restore
3639
with:
3740
path: ${{ inputs.key }}
3841
token: ${{ inputs.token }}
@@ -48,7 +51,7 @@ runs:
4851
4952
- if: ${{ inputs.value }}
5053
name: Save cached value
51-
uses: ./../../_actions/current/.github/actions/gh-cache/save
54+
uses: ./../../_actions/github/accessibility-scanner/current/.github/actions/gh-cache/save
5255
with:
5356
path: ${{ inputs.key }}
5457
token: ${{ inputs.token }}

action.yml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,15 @@ runs:
4444
working-directory: ${{ github.action_path }}
4545
shell: bash
4646
run: |
47-
mkdir -p /home/runner/work/_actions/current/.github/actions
48-
rsync -a .github/actions/ /home/runner/work/_actions/current/.github/actions/
49-
ls -ltra /home/runner/work/_actions/current/.github/actions
47+
RUNNER_WORK_DIR="$(realpath "${GITHUB_WORKSPACE}/../..")"
48+
ACTION_DIR="${RUNNER_WORK_DIR}/_actions/github/accessibility-scanner/current"
49+
mkdir -p "${ACTION_DIR}/.github/actions"
50+
if [ "$(realpath ".github/actions")" != "$(realpath "${ACTION_DIR}/.github/actions")" ]; then
51+
cp -a ".github/actions/." "${ACTION_DIR}/.github/actions/"
52+
fi
5053
- name: Restore cached results
5154
id: restore
52-
uses: ./../../_actions/current/.github/actions/gh-cache/cache
55+
uses: ./../../_actions/github/accessibility-scanner/current/.github/actions/gh-cache/cache
5356
with:
5457
key: ${{ inputs.cache_key }}
5558
token: ${{ inputs.token }}
@@ -66,20 +69,20 @@ runs:
6669
- if: ${{ inputs.login_url && inputs.username && inputs.password && !inputs.auth_context }}
6770
name: Authenticate
6871
id: auth
69-
uses: ./../../_actions/current/.github/actions/auth
72+
uses: ./../../_actions/github/accessibility-scanner/current/.github/actions/auth
7073
with:
7174
login_url: ${{ inputs.login_url }}
7275
username: ${{ inputs.username }}
7376
password: ${{ inputs.password }}
7477
- name: Find
7578
id: find
76-
uses: ./../../_actions/current/.github/actions/find
79+
uses: ./../../_actions/github/accessibility-scanner/current/.github/actions/find
7780
with:
7881
urls: ${{ inputs.urls }}
7982
auth_context: ${{ inputs.auth_context || steps.auth.outputs.auth_context }}
8083
- name: File
8184
id: file
82-
uses: ./../../_actions/current/.github/actions/file
85+
uses: ./../../_actions/github/accessibility-scanner/current/.github/actions/file
8386
with:
8487
findings: ${{ steps.find.outputs.findings }}
8588
repository: ${{ inputs.repository }}
@@ -96,7 +99,7 @@ runs:
9699
- if: ${{ inputs.skip_copilot_assignment != 'true' }}
97100
name: Fix
98101
id: fix
99-
uses: ./../../_actions/current/.github/actions/fix
102+
uses: ./../../_actions/github/accessibility-scanner/current/.github/actions/fix
100103
with:
101104
issues: ${{ steps.get_issues_from_filings.outputs.issues }}
102105
repository: ${{ inputs.repository }}
@@ -126,7 +129,7 @@ runs:
126129
FILINGS: ${{ steps.file.outputs.filings }}
127130
FIXINGS: ${{ steps.fix.outputs.fixings }}
128131
- name: Save cached results
129-
uses: ./../../_actions/current/.github/actions/gh-cache/cache
132+
uses: ./../../_actions/github/accessibility-scanner/current/.github/actions/gh-cache/cache
130133
with:
131134
key: ${{ inputs.cache_key }}
132135
value: ${{ steps.results.outputs.results }}

0 commit comments

Comments
 (0)