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
Copy file name to clipboardExpand all lines: content/actions/how-tos/write-workflows/choose-what-workflows-do/find-and-customize-actions.md
+44-2Lines changed: 44 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -66,9 +66,51 @@ An action's listing page includes the action's version and the workflow syntax r
66
66
67
67
### Adding an action from the same repository
68
68
69
-
If an action is defined in the same repository where your workflow file uses the action, you can reference the action with either the `{owner}/{repo}@{ref}` or `./path/to/dir` syntax in your workflow file.
69
+
If an action is defined in the same repository where your workflow file uses the action, you can reference the action with the `$/path/to/dir` self repository reference, or with the `{owner}/{repo}@{ref}` or `./path/to/dir` syntax in your workflow file. The `$/` syntax is not available in {% data variables.product.prodname_ghe_server %}.
70
+
71
+
Example repository file structure:
72
+
73
+
```shell
74
+
|-- hello-world (repository)
75
+
||__ .github
76
+
| └── workflows
77
+
| └── my-first-workflow.yml
78
+
| └── actions
79
+
||__ hello-world-action
80
+
| └── action.yml
81
+
```
82
+
83
+
We recommend referencing the action with the `$/path/to/dir` self repository reference. This resolves to the same repository at the running commit, so you do not need to check out the repository first. For more information about how `$/` compares to `{owner}/{repo}@{ref}` and `./`, see [AUTOTITLE](/actions/reference/workflows-and-actions/workflow-syntax#example-using-an-action-in-the-same-repository-as-the-workflow-at-the-running-commit-recommended).
84
+
85
+
Example workflow file using `$/`:
86
+
87
+
```yaml
88
+
jobs:
89
+
my_first_job:
90
+
runs-on: ubuntu-latest
91
+
steps:
92
+
# This step references an action in the same repository at the
93
+
# running commit. No repository checkout is required.
94
+
- name: Use hello-world-action
95
+
uses: $/.github/actions/hello-world-action
96
+
```
97
+
98
+
You can also reference the action with the relative `./path/to/dir` syntax, but it is more error-prone. The path is relative (`./`) to the default working directory (`github.workspace`, `$GITHUB_WORKSPACE`), so it requires a checkout step, and if the action checks out the repository to a location different than the workflow, the relative path must be updated.
70
99
71
-
{% data reusables.actions.workflows.section-referencing-an-action-from-the-same-repository %}
100
+
Example workflow file using `./`:
101
+
102
+
```yaml
103
+
jobs:
104
+
my_first_job:
105
+
runs-on: ubuntu-latest
106
+
steps:
107
+
# This step checks out a copy of your repository.
108
+
- name: My first step - check out repository
109
+
uses: {% data reusables.actions.action-checkout %}
110
+
# This step references the directory that contains the action.
111
+
- name: Use local hello-world-action
112
+
uses: ./.github/actions/hello-world-action
113
+
```
72
114
73
115
The `action.yml` file is used to provide metadata for the action. Learn about the content of this file in [AUTOTITLE](/actions/reference/workflows-and-actions/metadata-syntax).
Copy file name to clipboardExpand all lines: content/actions/reference/workflows-and-actions/metadata-syntax.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -339,6 +339,8 @@ runs:
339
339
- uses: actions/checkout@main
340
340
# References a subdirectory in a public GitHub repository at a specific branch, ref, or SHA
341
341
- uses: actions/aws/ec2@main
342
+
# References an action in the same repository at the running commit
343
+
- uses: $/.github/actions/my-action
342
344
# References a local action
343
345
- uses: ./.github/actions/my-action
344
346
# References a docker public registry action
@@ -347,6 +349,10 @@ runs:
347
349
- uses: docker://alpine:3.8
348
350
```
349
351
352
+
To reference an action stored in the same repository as your composite action, use the `$/` self repository reference, as shown in the `$/.github/actions/my-action` example above. It resolves to that repository at the running commit, so you do not need to check out the repository first, and it must not include an `@{ref}` suffix. The `$/` syntax is not available in {% data variables.product.prodname_ghe_server %}.
353
+
354
+
For a comparison of `$/`, `{owner}/{repo}@{ref}`, and `./`, see [AUTOTITLE](/actions/reference/workflows-and-actions/workflow-syntax#example-using-an-action-in-the-same-repository-as-the-workflow-at-the-running-commit-recommended).
355
+
350
356
#### `runs.steps[*].with`
351
357
352
358
**Optional** A `map` of the input parameters defined by the action. Each input parameter is a key/value pair. For more information, see [Example: Specifying inputs](#example-specifying-inputs).
Copy file name to clipboardExpand all lines: content/actions/reference/workflows-and-actions/workflow-syntax.md
+32-1Lines changed: 32 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -597,11 +597,42 @@ jobs:
597
597
uses: actions/aws/ec2@main
598
598
```
599
599
600
+
### Example: Using an action in the same repository as the workflow at the running commit (recommended)
601
+
602
+
`$/path/to/action`
603
+
604
+
The `$/` prefix is the self repository reference. It references an action stored in the same repository as the workflow or action that is currently running, and resolves to that repository at the running commit (the same SHA as the running workflow or action). You do not need to check out the repository first, so it is the recommended way to reference an action within its own repository.
605
+
606
+
The `$/` syntax is not available in {% data variables.product.prodname_ghe_server %}.
607
+
608
+
A `$/` reference must not include an `@{ref}` suffix. The ref is always the commit the running workflow or action is using, so a reference such as `$/actions/my-action@v1` is invalid.
609
+
610
+
`$/`always resolves against the repository of the file it appears in, not the repository that called it. For example, if a reusable workflow in one repository is called by a workflow in another repository, a `$/` reference in the called workflow resolves to the called workflow's repository, not the calling workflow's repository. This makes `$/` reliable for action composition, where a relative `./` path would instead resolve against whatever is checked out in the caller's workspace. For using `$/` in a composite action's steps, see [AUTOTITLE](/actions/reference/workflows-and-actions/metadata-syntax#runsstepsuses).
611
+
612
+
The following table compares the ways to reference an action.
613
+
614
+
| Syntax | Resolves to | Recommended for |
615
+
| ------ | ----------- | --------------- |
616
+
| `$/path/to/action` | The same repository as the running workflow or action, at the running commit | Actions in the same repository |
617
+
| `{owner}/{repo}@{ref}` | The specified repository at the specified ref | Actions in another repository |
618
+
| `./path/to/action` | A path in the runner's checked-out workspace, relative to the default working directory (`{% raw %}${{ github.workspace }}{% endraw %}`) | Edge cases only |
619
+
620
+
```yaml
621
+
on: [push]
622
+
623
+
jobs:
624
+
my_first_job:
625
+
runs-on: ubuntu-latest
626
+
steps:
627
+
# References an action in the same repository at the running commit
628
+
- uses: $/.github/actions/hello-world-action
629
+
```
630
+
600
631
### Example: Using an action in the same repository as the workflow
601
632
602
633
`./path/to/dir`
603
634
604
-
The path to the directory that contains the action in your workflow's repository. You must check out your repository before using the action.
635
+
The path to the directory that contains the action in your workflow's repository. You must check out your repository before using the action, and the `./` path resolves against the runner's workspace rather than the repository of the running workflow. For most cases, use the `$/` syntax shown above instead.
605
636
606
637
{% data reusables.actions.workflows.section-referencing-an-action-from-the-same-repository %}
Copy file name to clipboardExpand all lines: data/reusables/actions/allow-specific-actions-intro.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@
3
3
4
4
### Allowing select actions{% ifversion actions-workflow-policy %} and reusable workflows{% endif %} to run
5
5
6
-
When you choose {% data reusables.actions.policy-label-for-select-actions-workflows %}, local actions{% ifversion actions-workflow-policy %} and reusable workflows{% endif %} are allowed, and there are additional options for allowing other specific actions{% ifversion actions-workflow-policy %} and reusable workflows{% endif %}:
6
+
When you choose {% data reusables.actions.policy-label-for-select-actions-workflows %}, local actions (`./` and `$/`){% ifversion actions-workflow-policy %} and reusable workflows{% endif %} are allowed, and there are additional options for allowing other specific actions{% ifversion actions-workflow-policy %} and reusable workflows{% endif %}:
7
7
8
8
{% data reusables.repositories.settings-permissions-org-policy-note %}
*`$/.github/workflows/{filename}` for a reusable workflow in the same repository. This is the recommended syntax for referencing a reusable workflow in the same repository. This syntax is not available in {% data variables.product.prodname_ghe_server %}.
1
2
*`{owner}/{repo}/.github/workflows/{filename}@{ref}` for reusable workflows in {% ifversion fpt %}public and private{% elsif ghec or ghes %}public, internal and private{% endif %} repositories.
2
3
*`./.github/workflows/{filename}` for reusable workflows in the same repository.
3
4
4
-
In the first option,`{ref}` can be a SHA, a release tag, or a branch name. If a release tag and a branch have the same name, the release tag takes precedence over the branch name. Using the commit SHA is the safest option for stability and security. For more information, see [AUTOTITLE](/actions/reference/security/secure-use#reusing-third-party-workflows).
5
+
When you reference a reusable workflow with `{owner}/{repo}` and `@{ref}`, the`{ref}` can be a SHA, a release tag, or a branch name. If a release tag and a branch have the same name, the release tag takes precedence over the branch name. Using the commit SHA is the safest option for stability and security. For more information, see [AUTOTITLE](/actions/reference/security/secure-use#reusing-third-party-workflows).
5
6
6
-
If you use the second syntax option (without `{owner}/{repo}` and `@{ref}`) the called workflow is from the same commit as the caller workflow. Ref prefixes such as `refs/heads` and `refs/tags` are not allowed. You cannot use contexts or expressions in this keyword.
7
+
When you reference a reusable workflow in the same repository using `$/` or `./`(without `{owner}/{repo}` and `@{ref}`), the called workflow is from the same commit as the caller workflow. A `$/` reference must not include an `@{ref}` suffix, and `$/` is not available in {% data variables.product.prodname_ghe_server %}. Ref prefixes such as `refs/heads` and `refs/tags` are not allowed. You cannot use contexts or expressions in this keyword.
0 commit comments