Skip to content

Commit 472bf85

Browse files
authored
feat: Use relative paths to reference sub-actions in composite actions (#59)
Fixes github/continuous-ai-for-accessibility#87 (Hubber access only) Fixes github/continuous-ai-for-accessibility#81 (Hubber access only) ### Problem `uses: github/accessibility-scanner@main` currently fails with the following error— > Error: Can't find 'action.yml', 'action.yaml' or 'Dockerfile' under '/home/runner/work/accessibility-sandbox/accessibility-sandbox/.github/actions/gh-cache/cache'. Did you forget to run actions/checkout before running your local action? —this PR makes it work. ### Solution This PR basically moves the preparatory `cp` workflow step [we used to require](https://github.com/github/accessibility-scanner/tree/bc0c7650825e578c243347fe551f247826bcb70e?tab=readme-ov-file#1-add-a-workflow-file) into the composite action(s) itself. This PR is a superior alternative to c262469: 1. It restores our ability to merge `main` directly into `v2`, which simplifies backports (e.g. dependency updates that Dependabot opens for `main`). 2. It means referencing a point release (e.g. `uses: github/[email protected]`) _only_ runs code from that release (rather than a mix of `v2.4.0` and (newer) `v2` code). ### Testing - I tested using `uses: github/accessibility-scanner@smockle/restore-relative-paths`, and it worked: https://github.com/github/accessibility-sandbox/actions/runs/18943849865 (Hubber access only) - I tested using a sub-action directly (e.g. `uses: github/accessibility-scanner/.github/actions/gh-cache/cache@smockle/restore-relative-paths`), and it worked: https://github.com/github/accessibility-sandbox/actions/runs/18945624950 (Hubber access only) - The “Test” CI check passed: https://github.com/github/accessibility-scanner/actions/runs/18944419202/job/54092648187?pr=59
2 parents d00fadd + 74e1464 commit 472bf85

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ inputs:
1414
fail_on_cache_miss:
1515
description: "Fail the workflow if cached item is not found."
1616
required: false
17-
default: 'false'
17+
default: "false"
1818

1919
outputs:
2020
value:
@@ -24,8 +24,15 @@ outputs:
2424
runs:
2525
using: "composite"
2626
steps:
27+
- name: Make sub-actions referenceable
28+
working-directory: ${{ github.action_path }}
29+
shell: bash
30+
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
2734
- name: Restore cached value
28-
uses: ./.github/actions/gh-cache/restore
35+
uses: ./../../_actions/current/.github/actions/gh-cache/restore
2936
with:
3037
path: ${{ inputs.key }}
3138
token: ${{ inputs.token }}
@@ -41,7 +48,7 @@ runs:
4148
4249
- if: ${{ inputs.value }}
4350
name: Save cached value
44-
uses: ./.github/actions/gh-cache/save
51+
uses: ./../../_actions/current/.github/actions/gh-cache/save
4552
with:
4653
path: ${{ inputs.key }}
4754
token: ${{ inputs.token }}

action.yml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,16 @@ outputs:
4040
runs:
4141
using: "composite"
4242
steps:
43+
- name: Make sub-actions referenceable
44+
working-directory: ${{ github.action_path }}
45+
shell: bash
46+
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
4350
- name: Restore cached results
4451
id: restore
45-
uses: ./.github/actions/gh-cache/cache
52+
uses: ./../../_actions/current/.github/actions/gh-cache/cache
4653
with:
4754
key: ${{ inputs.cache_key }}
4855
token: ${{ inputs.token }}
@@ -59,20 +66,20 @@ runs:
5966
- if: ${{ inputs.login_url && inputs.username && inputs.password && !inputs.auth_context }}
6067
name: Authenticate
6168
id: auth
62-
uses: ./.github/actions/auth
69+
uses: ./../../_actions/current/.github/actions/auth
6370
with:
6471
login_url: ${{ inputs.login_url }}
6572
username: ${{ inputs.username }}
6673
password: ${{ inputs.password }}
6774
- name: Find
6875
id: find
69-
uses: ./.github/actions/find
76+
uses: ./../../_actions/current/.github/actions/find
7077
with:
7178
urls: ${{ inputs.urls }}
7279
auth_context: ${{ inputs.auth_context || steps.auth.outputs.auth_context }}
7380
- name: File
7481
id: file
75-
uses: ./.github/actions/file
82+
uses: ./../../_actions/current/.github/actions/file
7683
with:
7784
findings: ${{ steps.find.outputs.findings }}
7885
repository: ${{ inputs.repository }}
@@ -89,7 +96,7 @@ runs:
8996
- if: ${{ inputs.skip_copilot_assignment != 'true' }}
9097
name: Fix
9198
id: fix
92-
uses: ./.github/actions/fix
99+
uses: ./../../_actions/current/.github/actions/fix
93100
with:
94101
issues: ${{ steps.get_issues_from_filings.outputs.issues }}
95102
repository: ${{ inputs.repository }}
@@ -119,7 +126,7 @@ runs:
119126
FILINGS: ${{ steps.file.outputs.filings }}
120127
FIXINGS: ${{ steps.fix.outputs.fixings }}
121128
- name: Save cached results
122-
uses: ./.github/actions/gh-cache/cache
129+
uses: ./../../_actions/current/.github/actions/gh-cache/cache
123130
with:
124131
key: ${{ inputs.cache_key }}
125132
value: ${{ steps.results.outputs.results }}

0 commit comments

Comments
 (0)