fix(docs): Updated the documentation on using local workflow (#29436)
Co-authored-by: Rachael Rose Renk <91027132+rachaelrenk@users.noreply.github.com>
This commit is contained in:
@@ -71,30 +71,7 @@ An action's listing page includes the action's version and the workflow syntax r
|
|||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
Example repository file structure:
|
{% data reusables.actions.workflows.section-referencing-an-action-from-the-same-repository %}
|
||||||
|
|
||||||
```shell
|
|
||||||
|-- hello-world (repository)
|
|
||||||
| |__ .github
|
|
||||||
| └── workflows
|
|
||||||
| └── my-first-workflow.yml
|
|
||||||
| └── actions
|
|
||||||
| |__ hello-world-action
|
|
||||||
| └── action.yml
|
|
||||||
```
|
|
||||||
|
|
||||||
Example workflow file:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
# This step checks out a copy of your repository.
|
|
||||||
- uses: {% data reusables.actions.action-checkout %}
|
|
||||||
# This step references the directory that contains the action.
|
|
||||||
- uses: ./.github/actions/hello-world-action
|
|
||||||
```
|
|
||||||
|
|
||||||
The `action.yml` file is used to provide metadata for the action. Learn about the content of this file in "[AUTOTITLE](/actions/creating-actions/metadata-syntax-for-github-actions)."
|
The `action.yml` file is used to provide metadata for the action. Learn about the content of this file in "[AUTOTITLE](/actions/creating-actions/metadata-syntax-for-github-actions)."
|
||||||
|
|
||||||
|
|||||||
@@ -512,15 +512,7 @@ jobs:
|
|||||||
|
|
||||||
The path to the directory that contains the action in your workflow's repository. You must check out your repository before using the action.
|
The path to the directory that contains the action in your workflow's repository. You must check out your repository before using the action.
|
||||||
|
|
||||||
```yaml
|
{% data reusables.actions.workflows.section-referencing-an-action-from-the-same-repository %}
|
||||||
jobs:
|
|
||||||
my_first_job:
|
|
||||||
steps:
|
|
||||||
- name: Check out repository
|
|
||||||
uses: {% data reusables.actions.action-checkout %}
|
|
||||||
- name: Use local my-action
|
|
||||||
uses: ./.github/actions/my-action
|
|
||||||
```
|
|
||||||
|
|
||||||
### Example: Using a Docker Hub action
|
### Example: Using a Docker Hub action
|
||||||
|
|
||||||
@@ -634,7 +626,7 @@ You can also use a `run` step to run a script. For more information, see "[AUTOT
|
|||||||
You can override the default shell settings in the runner's operating system using the `shell` keyword. You can use built-in `shell` keywords, or you can define a custom set of shell options. The shell command that is run internally executes a temporary file that contains the commands specified in the `run` keyword.
|
You can override the default shell settings in the runner's operating system using the `shell` keyword. You can use built-in `shell` keywords, or you can define a custom set of shell options. The shell command that is run internally executes a temporary file that contains the commands specified in the `run` keyword.
|
||||||
|
|
||||||
| Supported platform | `shell` parameter | Description | Command run internally |
|
| Supported platform | `shell` parameter | Description | Command run internally |
|
||||||
|--------------------|-------------------|-------------|------------------------|
|
| ------------------ | ----------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------- |
|
||||||
| Linux / macOS | unspecified | The default shell on non-Windows platforms. Note that this runs a different command to when `bash` is specified explicitly. If `bash` is not found in the path, this is treated as `sh`. | `bash -e {0}` |
|
| Linux / macOS | unspecified | The default shell on non-Windows platforms. Note that this runs a different command to when `bash` is specified explicitly. If `bash` is not found in the path, this is treated as `sh`. | `bash -e {0}` |
|
||||||
| All | `bash` | The default shell on non-Windows platforms with a fallback to `sh`. When specifying a bash shell on Windows, the bash shell included with Git for Windows is used. | `bash --noprofile --norc -eo pipefail {0}` |
|
| All | `bash` | The default shell on non-Windows platforms with a fallback to `sh`. When specifying a bash shell on Windows, the bash shell included with Git for Windows is used. | `bash --noprofile --norc -eo pipefail {0}` |
|
||||||
| All | `pwsh` | The PowerShell Core. {% data variables.product.prodname_dotcom %} appends the extension `.ps1` to your script name. | `pwsh -command ". '{0}'"` |
|
| All | `pwsh` | The PowerShell Core. {% data variables.product.prodname_dotcom %} appends the extension `.ps1` to your script name. | `pwsh -command ". '{0}'"` |
|
||||||
@@ -1165,7 +1157,7 @@ For more information about branch, tag, and path filter syntax, see "[`on.<push>
|
|||||||
### Patterns to match branches and tags
|
### Patterns to match branches and tags
|
||||||
|
|
||||||
| Pattern | Description | Example matches |
|
| Pattern | Description | Example matches |
|
||||||
|---------|------------------------|---------|
|
| ------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- |
|
||||||
| `feature/*` | The `*` wildcard matches any character, but does not match slash (`/`). | `feature/my-branch`<br/><br/>`feature/your-branch` |
|
| `feature/*` | The `*` wildcard matches any character, but does not match slash (`/`). | `feature/my-branch`<br/><br/>`feature/your-branch` |
|
||||||
| `feature/**` | The `**` wildcard matches any character including slash (`/`) in branch and tag names. | `feature/beta-a/my-branch`<br/><br/>`feature/your-branch`<br/><br/>`feature/mona/the/octocat` |
|
| `feature/**` | The `**` wildcard matches any character including slash (`/`) in branch and tag names. | `feature/beta-a/my-branch`<br/><br/>`feature/your-branch`<br/><br/>`feature/mona/the/octocat` |
|
||||||
| `main`<br/><br/>`releases/mona-the-octocat` | Matches the exact name of a branch or tag name. | `main`<br/><br/>`releases/mona-the-octocat` |
|
| `main`<br/><br/>`releases/mona-the-octocat` | Matches the exact name of a branch or tag name. | `main`<br/><br/>`releases/mona-the-octocat` |
|
||||||
@@ -1180,18 +1172,18 @@ For more information about branch, tag, and path filter syntax, see "[`on.<push>
|
|||||||
Path patterns must match the whole path, and start from the repository's root.
|
Path patterns must match the whole path, and start from the repository's root.
|
||||||
|
|
||||||
| Pattern | Description of matches | Example matches |
|
| Pattern | Description of matches | Example matches |
|
||||||
|---------|------------------------|-----------------|
|
| --------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
|
||||||
| `'*'` | The `*` wildcard matches any character, but does not match slash (`/`). The `*` character is a special character in YAML. When you start a pattern with `*`, you must use quotes. | `README.md`<br/><br/>`server.rb` |
|
| `'*'` | The `*` wildcard matches any character, but does not match slash (`/`). The `*` character is a special character in YAML. When you start a pattern with `*`, you must use quotes. | `README.md`<br/><br/>`server.rb` |
|
||||||
| `'*.jsx?'` | The `?` character matches zero or one of the preceding character. | `page.js`<br/><br/>`page.jsx` |
|
| `'*.jsx?'` | The `?` character matches zero or one of the preceding character. | `page.js`<br/><br/>`page.jsx` |
|
||||||
| `'**'` | The `**` wildcard matches any character including slash (`/`). This is the default behavior when you don't use a `path` filter. | `all/the/files.md` |
|
| `'**'` | The `**` wildcard matches any character including slash (`/`). This is the default behavior when you don't use a `path` filter. | `all/the/files.md` |
|
||||||
| `'*.js'` | The `*` wildcard matches any character, but does not match slash (`/`). Matches all `.js` files at the root of the repository. | `app.js`<br/><br/>`index.js`
|
| `'*.js'` | The `*` wildcard matches any character, but does not match slash (`/`). Matches all `.js` files at the root of the repository. | `app.js`<br/><br/>`index.js` |
|
||||||
| `'**.js'` | Matches all `.js` files in the repository. | `index.js`<br/><br/>`js/index.js`<br/><br/>`src/js/app.js` |
|
| `'**.js'` | Matches all `.js` files in the repository. | `index.js`<br/><br/>`js/index.js`<br/><br/>`src/js/app.js` |
|
||||||
| `docs/*` | All files within the root of the `docs` directory, at the root of the repository. | `docs/README.md`<br/><br/>`docs/file.txt` |
|
| `docs/*` | All files within the root of the `docs` directory, at the root of the repository. | `docs/README.md`<br/><br/>`docs/file.txt` |
|
||||||
| `docs/**` | Any files in the `/docs` directory at the root of the repository. | `docs/README.md`<br/><br/>`docs/mona/octocat.txt` |
|
| `docs/**` | Any files in the `/docs` directory at the root of the repository. | `docs/README.md`<br/><br/>`docs/mona/octocat.txt` |
|
||||||
| `docs/**/*.md` | A file with a `.md` suffix anywhere in the `docs` directory. | `docs/README.md`<br/><br/>`docs/mona/hello-world.md`<br/><br/>`docs/a/markdown/file.md`
|
| `docs/**/*.md` | A file with a `.md` suffix anywhere in the `docs` directory. | `docs/README.md`<br/><br/>`docs/mona/hello-world.md`<br/><br/>`docs/a/markdown/file.md` |
|
||||||
| `'**/docs/**'` | Any files in a `docs` directory anywhere in the repository. | `docs/hello.md`<br/><br/>`dir/docs/my-file.txt`<br/><br/>`space/docs/plan/space.doc`
|
| `'**/docs/**'` | Any files in a `docs` directory anywhere in the repository. | `docs/hello.md`<br/><br/>`dir/docs/my-file.txt`<br/><br/>`space/docs/plan/space.doc` |
|
||||||
| `'**/README.md'` | A README.md file anywhere in the repository. | `README.md`<br/><br/>`js/README.md`
|
| `'**/README.md'` | A README.md file anywhere in the repository. | `README.md`<br/><br/>`js/README.md` |
|
||||||
| `'**/*src/**'` | Any file in a folder with a `src` suffix anywhere in the repository. | `a/src/app.js`<br/><br/>`my-src/code/js/app.js`
|
| `'**/*src/**'` | Any file in a folder with a `src` suffix anywhere in the repository. | `a/src/app.js`<br/><br/>`my-src/code/js/app.js` |
|
||||||
| `'**/*-post.md'` | A file with the suffix `-post.md` anywhere in the repository. | `my-post.md`<br/><br/>`path/their-post.md` |
|
| `'**/*-post.md'` | A file with the suffix `-post.md` anywhere in the repository. | `my-post.md`<br/><br/>`path/their-post.md` |
|
||||||
| `'**/migrate-*.sql'` | A file with the prefix `migrate-` and suffix `.sql` anywhere in the repository. | `migrate-10909.sql`<br/><br/>`db/migrate-v1.0.sql`<br/><br/>`db/sept/migrate-v1.sql` |
|
| `'**/migrate-*.sql'` | A file with the prefix `migrate-` and suffix `.sql` anywhere in the repository. | `migrate-10909.sql`<br/><br/>`db/migrate-v1.0.sql`<br/><br/>`db/sept/migrate-v1.sql` |
|
||||||
| `'*.md'`<br/><br/>`'!README.md'` | Using an exclamation mark (`!`) in front of a pattern negates it. When a file matches a pattern and also matches a negative pattern defined later in the file, the file will not be included. | `hello.md`<br/><br/>_Does not match_<br/><br/>`README.md`<br/><br/>`docs/hello.md` |
|
| `'*.md'`<br/><br/>`'!README.md'` | Using an exclamation mark (`!`) in front of a pattern negates it. When a file matches a pattern and also matches a negative pattern defined later in the file, the file will not be included. | `hello.md`<br/><br/>_Does not match_<br/><br/>`README.md`<br/><br/>`docs/hello.md` |
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
Example repository file structure:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
|-- hello-world (repository)
|
||||||
|
| |__ .github
|
||||||
|
| └── workflows
|
||||||
|
| └── my-first-workflow.yml
|
||||||
|
| └── actions
|
||||||
|
| |__ hello-world-action
|
||||||
|
| └── action.yml
|
||||||
|
```
|
||||||
|
|
||||||
|
The path is relative (`./`) to the default working directory (`github.workspace`, `$GITHUB_WORKSPACE`). If the action checks out the repository to a location different than the workflow, the relative path used for local actions must be updated.
|
||||||
|
|
||||||
|
Example workflow file:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
jobs:
|
||||||
|
my_first_job:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
# This step checks out a copy of your repository.
|
||||||
|
- name: My first step - check out repository
|
||||||
|
uses: {% data reusables.actions.action-checkout %}
|
||||||
|
# This step references the directory that contains the action.
|
||||||
|
- name: Use local hello-world-action
|
||||||
|
uses: ./.github/actions/hello-world-action
|
||||||
|
```
|
||||||
Reference in New Issue
Block a user