You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reusable Workflow Context is a GitHub Action that enables you to access reusable workflow context within a running reusable workflow. This action is intended to address the limitations of GitHub. Namely the fact that [neither reusable workflow ref nor reusable workflow sha are available in the context of a running reusable workflow](https://github.com/actions/toolkit/issues/1264).
4
+
5
+
## Usage
6
+
7
+
To use the action, add the following step to your GitHub Actions reusable workflow:
8
+
9
+
```
10
+
- id: reusable-workflow
11
+
name: Retrieve reusable workflow context
12
+
uses: ipdxco/reusable-workflow-context@v1
13
+
with:
14
+
path: the-name-of-the-reusable-workflow.yml
15
+
```
16
+
17
+
See the [example reusable workflow](./.github/workflows/reusable.yml) that we use to [test](./.github/workflows) this action.
18
+
19
+
### Inputs
20
+
21
+
*`path`: The path where the reusable workflow is located. Required. We suggest using the name of the reusable workflow as the path.
22
+
23
+
### Outputs
24
+
25
+
*`ref`: For a reusable workflow executing an action, this is the ref of the reusable workflow being executed.
26
+
*`sha`: For a reusable workflow executing an action, this is the sha of the reusable workflow being executed.
27
+
28
+
## How it works
29
+
30
+
The action uses GitHub API to retrieve the reusable workflows referenced by the current worfklow run. It then filters the reusable workflows based on the path input and selects the first matching workflow. Finally, it exposes the `ref` and `sha` of the reusable workflow it found.
31
+
32
+
## Known limitations
33
+
34
+
1. If you use multiple reusable workflows in your workflow, you should watch out for possible path clashes.
35
+
2. If you use multiple instances of a reusable workflow with different ref/sha, you should be concious of the fact that the action will only return the ref/sha of the first instance of the reusable workflow that it finds in each instance.
36
+
3. If you use request a reusable workflow by sha, the ref output of the action will be empty.
0 commit comments