Skip to content

Commit 91ed1d3

Browse files
committed
expand documentation on referencing actions in workflows
1 parent 2495333 commit 91ed1d3

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

learn-pr/github/github-actions-automate-tasks/1-introduction.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Introduction
44
metadata:
55
title: Introduction
66
description: An introduction to GitHub Actions and workflows.
7-
ms.date: 10/08/2024
7+
ms.date: 05/01/2025
88
author: juliakm
99
ms.author: jukullam
1010
ms.topic: unit

learn-pr/github/github-actions-automate-tasks/includes/2-github-actions-automate-development-tasks.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,48 @@ The last part of this workflow file sets the `MY_NAME` variable value for this w
156156

157157
For more information on workflow syntax, see [Workflow syntax for GitHub Actions](https://docs.github.com/actions/using-workflows/workflow-syntax-for-github-actions?azure-portal=true)
158158

159+
## Referencing Actions in Workflows
160+
161+
When creating workflows in GitHub Actions, you can reference actions from various sources. These actions can be used to automate tasks in your workflows. Below are the primary sources where workflows can reference actions:
162+
163+
1. **A published Docker container image on Docker Hub**
164+
Workflows can reference actions that are published as Docker container images on Docker Hub. These actions are containerized and include all dependencies required to execute the action. To use such an action, you specify the Docker image in the `uses` attribute of your workflow step. For example:
165+
```yml
166+
steps:
167+
- name: Run a Docker action
168+
uses: docker://<docker-image-name>:<tag>
169+
```
170+
171+
2. **Any public repository**
172+
Actions hosted in public repositories can be directly referenced in your workflows. These actions are accessible to anyone and can be used by specifying the repository name and version (Git ref, SHA, or tag) in the `uses` attribute. For example:
173+
```yml
174+
steps:
175+
- name: Use a public action
176+
uses: actions/checkout@v3
177+
```
178+
179+
3. **The same repository as your workflow file**
180+
You can reference actions stored in the same repository as your workflow file. This is useful for custom actions that are specific to your project. To reference such actions, use a relative path to the action's directory. For example:
181+
```yml
182+
steps:
183+
- name: Use a local action
184+
uses: ./path-to-action
185+
```
186+
187+
4. **An enterprise marketplace**
188+
If your organization uses GitHub Enterprise, you can reference actions from your enterprise's private marketplace. These actions are curated and managed by your organization, ensuring compliance with internal standards. For example:
189+
```yml
190+
steps:
191+
- name: Use an enterprise marketplace action
192+
uses: enterprise-org/action-name@v1
193+
```
194+
195+
### Additional Notes
196+
- Actions in private repositories can also be referenced, but they require proper authentication and permissions.
197+
- When referencing actions, always specify a version (Git ref, SHA, or tag) to ensure consistency and avoid unexpected changes.
198+
199+
For more information, see [Referencing actions in workflows](https://docs.github.com/actions/using-workflows/referencing-actions-in-workflows?azure-portal=true).
200+
159201
## GitHub-hosted versus self-hosted runners
160202

161203
We briefly mentioned runners as being associated with a job. A runner is simply a server that has the GitHub Actions runner application installed. In the previous workflow example, there was a `runs-on: ubuntu-latest` attribute within the jobs block, which told the workflow that the job will run using the GitHub-hosted runner that's running in the `ubuntu-latest` environment.

0 commit comments

Comments
 (0)