Skip to content

Commit 78a0b0e

Browse files
authored
Merge pull request #45347 from github/repo-sync
Repo sync
2 parents 6f69b51 + f28f18c commit 78a0b0e

9 files changed

Lines changed: 243 additions & 23 deletions

File tree

content/actions/how-tos/write-workflows/choose-what-workflows-do/find-and-customize-actions.md

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,51 @@ An action's listing page includes the action's version and the workflow syntax r
6666

6767
### Adding an action from the same repository
6868

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.
7099

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+
```
72114

73115
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).
74116

content/actions/reference/workflows-and-actions/metadata-syntax.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,8 @@ runs:
339339
- uses: actions/checkout@main
340340
# References a subdirectory in a public GitHub repository at a specific branch, ref, or SHA
341341
- uses: actions/aws/ec2@main
342+
# References an action in the same repository at the running commit
343+
- uses: $/.github/actions/my-action
342344
# References a local action
343345
- uses: ./.github/actions/my-action
344346
# References a docker public registry action
@@ -347,6 +349,10 @@ runs:
347349
- uses: docker://alpine:3.8
348350
```
349351

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+
350356
#### `runs.steps[*].with`
351357

352358
**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).

content/actions/reference/workflows-and-actions/workflow-syntax.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,11 +597,42 @@ jobs:
597597
uses: actions/aws/ec2@main
598598
```
599599

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+
600631
### Example: Using an action in the same repository as the workflow
601632

602633
`./path/to/dir`
603634

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.
605636

606637
{% data reusables.actions.workflows.section-referencing-an-action-from-the-same-repository %}
607638

data/reusables/actions/allow-specific-actions-intro.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
### Allowing select actions{% ifversion actions-workflow-policy %} and reusable workflows{% endif %} to run
55

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 %}:
77

88
{% data reusables.repositories.settings-permissions-org-policy-note %}
99

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
* `$/.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 %}.
12
* `{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.
23
* `./.github/workflows/{filename}` for reusable workflows in the same repository.
34

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).
56

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.

data/reusables/actions/uses-keyword-example.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ jobs:
44
uses: octo-org/this-repo/.github/workflows/workflow-1.yml@172239021f7ba04fe7327647b213799853a9eb89
55
call-workflow-2-in-local-repo:
66
uses: ./.github/workflows/workflow-2.yml
7+
# The `$/` syntax is not available in GitHub Enterprise Server.
8+
call-workflow-in-same-repo-at-running-commit:
9+
uses: $/.github/workflows/workflow-2.yml
710
call-workflow-in-another-repo:
811
uses: octo-org/another-repo/.github/workflows/workflow.yml@v1
912
```

src/fixtures/tests/playwright-rendering.spec.ts

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,58 @@ test('use sidebar to go to Hello World page', async ({ page }) => {
5252
await expect(page).toHaveTitle(/Hello World - GitHub Docs/)
5353
})
5454

55+
test('sidebar highlights the clicked item optimistically while navigation is pending', async ({
56+
page,
57+
}) => {
58+
// Article pages are getServerSideProps routes, so router.asPath (and thus the real
59+
// aria-current) only updates after the destination loads. The sidebar marks the
60+
// clicked link with a visual-only `data-pending` accent so the click is acknowledged
61+
// immediately. Throttle the client-side data fetch so the navigation stays pending
62+
// long enough to observe that intermediate state.
63+
await page.goto('/get-started')
64+
await page.getByTestId('product-sidebar').getByText('Start your journey').click()
65+
66+
const sidebar = page.getByTestId('product-sidebar')
67+
const helloWorld = sidebar.getByRole('link', { name: 'Hello World' })
68+
const linkRewriting = sidebar.getByRole('link', { name: 'Link rewriting' })
69+
70+
// Hold the next data request open until we release it, so navigation stays pending.
71+
let releaseNavigation = () => {}
72+
const navigationHeld = new Promise<void>((resolve) => {
73+
releaseNavigation = resolve
74+
})
75+
await page.route('**/_next/data/**', async (route) => {
76+
await navigationHeld
77+
await route.continue()
78+
})
79+
80+
await helloWorld.click()
81+
82+
// While pending: the clicked link carries the optimistic visual marker, but the URL
83+
// and the semantic aria-current still reflect the (still-loaded) get-started page.
84+
await expect(helloWorld).toHaveAttribute('data-pending', '')
85+
await expect(helloWorld).not.toHaveAttribute('aria-current', 'page')
86+
await expect(page).not.toHaveURL(/hello-world/)
87+
88+
// Let the navigation finish: the marker gives way to a real aria-current.
89+
releaseNavigation()
90+
await expect(page).toHaveURL(/\/en\/get-started\/start-your-journey\/hello-world/)
91+
await expect(helloWorld).toHaveAttribute('aria-current', 'page')
92+
await expect(helloWorld).not.toHaveAttribute('data-pending', '')
93+
94+
// A modifier-click (open in new tab) must NOT move the optimistic selection.
95+
// handleNavClick bails on modifier clicks, so pendingHref is never set: the current
96+
// page keeps its URL, its aria-current, and the clicked link gets no data-pending.
97+
// Use ControlOrMeta so the real "open in new tab" modifier is sent per-platform
98+
// (Ctrl on Linux/Windows CI, Meta on macOS). The click opens a background tab we
99+
// don't need to assert on; catch any popup so it doesn't leak.
100+
page.on('popup', (popup) => popup.close())
101+
await linkRewriting.click({ modifiers: ['ControlOrMeta'] })
102+
await expect(linkRewriting).not.toHaveAttribute('data-pending', '')
103+
await expect(helloWorld).toHaveAttribute('aria-current', 'page')
104+
await expect(page).toHaveURL(/\/en\/get-started\/start-your-journey\/hello-world/)
105+
})
106+
55107
test('press "/" to open the search overlay', async ({ page }) => {
56108
await page.goto('/')
57109
await turnOffExperimentsInPage(page)

src/landings/components/SidebarProduct.module.scss

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,15 @@
77
// so a top-level article like "Quickstart" gets only the subtle background pill
88
// and no green bar. Restore the bar for active top-level leaves to match nested
99
// items. Brand's classes are hashed, so match on the stable substrings.
10+
//
11+
// This also covers `[data-pending]` — the optimistic marker on a just-clicked item
12+
// (see the pending rules below) — so a clicked top-level leaf gets the bar too.
1013
:global([class*="NavList__item--leaf"][class*="NavList__item--level-1"])
1114
:global([class*="NavList__link"])[aria-current]:not(
1215
[aria-current="false"]
13-
)::before {
16+
)::before,
17+
:global([class*="NavList__item--leaf"][class*="NavList__item--level-1"])
18+
:global([class*="NavList__link"])[data-pending]::before {
1419
content: "";
1520
position: absolute;
1621
// Level-1 links are shorter (~24px) than nested leaves, so use a small inset
@@ -25,4 +30,38 @@
2530
border-radius: var(--base-size-2);
2631
background-color: var(--brand-NavList-activeIndicator-color);
2732
}
33+
34+
// Optimistic "pending" highlight. Article pages are getServerSideProps routes and can
35+
// be slow to load, so router.asPath — and thus aria-current — only updates once the
36+
// page has loaded. We keep aria-current on the *loaded* page (assistive tech must not
37+
// be told a still-loading destination is the current page), and instead mark the
38+
// just-clicked link with `data-pending` for a VISUAL-ONLY accent. Brand couples its
39+
// active styling to `[aria-current]`, so mirror that treatment here for `[data-pending]`.
40+
// data-pending is only set while a *different* page is loading, so it never collides
41+
// with the real aria-current item.
42+
:global([class*="NavList__link"])[data-pending] {
43+
color: var(--brand-color-text-default);
44+
background-color: var(--brand-color-canvas-subtle);
45+
}
46+
47+
// Nested leaves: brand moves the background pill onto the label and adds a leading
48+
// accent bar (mirrors `.item--leaf:not(.item--level-1) .link[aria-current]`).
49+
:global([class*="NavList__item--leaf"]:not([class*="NavList__item--level-1"]))
50+
:global([class*="NavList__link"])[data-pending] {
51+
background-color: transparent;
52+
53+
:global([class*="NavList__labelArea"]) {
54+
background-color: var(--brand-color-canvas-subtle);
55+
}
56+
57+
&::before {
58+
content: "";
59+
position: absolute;
60+
inset-block: var(--base-size-8);
61+
inset-inline-start: 0;
62+
width: var(--base-size-4);
63+
border-radius: var(--base-size-2);
64+
background-color: var(--brand-NavList-activeIndicator-color);
65+
}
66+
}
2867
}

0 commit comments

Comments
 (0)