{"meta":{"title":"Using pre-written building blocks in your workflow","intro":"You can use and customize pre-written actions to power your workflow.","product":"GitHub Actions","breadcrumbs":[{"href":"/en/actions","title":"GitHub Actions"},{"href":"/en/actions/how-tos","title":"How-tos"},{"href":"/en/actions/how-tos/write-workflows","title":"Write workflows"},{"href":"/en/actions/how-tos/write-workflows/choose-what-workflows-do","title":"Choose what workflows do"},{"href":"/en/actions/how-tos/write-workflows/choose-what-workflows-do/find-and-customize-actions","title":"Find and customize actions"}],"documentType":"article"},"body":"# Using pre-written building blocks in your workflow\n\nYou can use and customize pre-written actions to power your workflow.\n\n## Browsing Marketplace actions in the workflow editor\n\nYou can search and browse actions directly in your repository's workflow editor. From the sidebar, you can search for a specific action, view featured actions, and browse featured categories. You can also view the number of stars an action has received from the GitHub community.\n\n1. In your repository, browse to the workflow file you want to edit.\n2. In the upper right corner of the file view, to open the workflow editor, click <svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-pencil\" aria-label=\"Edit file\" role=\"img\"><path d=\"M11.013 1.427a1.75 1.75 0 0 1 2.474 0l1.086 1.086a1.75 1.75 0 0 1 0 2.474l-8.61 8.61c-.21.21-.47.364-.756.445l-3.251.93a.75.75 0 0 1-.927-.928l.929-3.25c.081-.286.235-.547.445-.758l8.61-8.61Zm.176 4.823L9.75 4.81l-6.286 6.287a.253.253 0 0 0-.064.108l-.558 1.953 1.953-.558a.253.253 0 0 0 .108-.064Zm1.238-3.763a.25.25 0 0 0-.354 0L10.811 3.75l1.439 1.44 1.263-1.263a.25.25 0 0 0 0-.354Z\"></path></svg>.\n   ![Screenshot of a workflow file showing the header section. The pencil icon for editing files is highlighted with a dark orange outline.](/assets/images/help/repository/actions-edit-workflow-file.png)\n3. To the right of the editor, use the GitHub Marketplace sidebar to browse actions. Actions with the <svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-verified\" aria-label=\"Creator verified by GitHub\" role=\"img\"><path d=\"m9.585.52.929.68c.153.112.331.186.518.215l1.138.175a2.678 2.678 0 0 1 2.24 2.24l.174 1.139c.029.187.103.365.215.518l.68.928a2.677 2.677 0 0 1 0 3.17l-.68.928a1.174 1.174 0 0 0-.215.518l-.175 1.138a2.678 2.678 0 0 1-2.241 2.241l-1.138.175a1.17 1.17 0 0 0-.518.215l-.928.68a2.677 2.677 0 0 1-3.17 0l-.928-.68a1.174 1.174 0 0 0-.518-.215L3.83 14.41a2.678 2.678 0 0 1-2.24-2.24l-.175-1.138a1.17 1.17 0 0 0-.215-.518l-.68-.928a2.677 2.677 0 0 1 0-3.17l.68-.928c.112-.153.186-.331.215-.518l.175-1.14a2.678 2.678 0 0 1 2.24-2.24l1.139-.175c.187-.029.365-.103.518-.215l.928-.68a2.677 2.677 0 0 1 3.17 0ZM7.303 1.728l-.927.68a2.67 2.67 0 0 1-1.18.489l-1.137.174a1.179 1.179 0 0 0-.987.987l-.174 1.136a2.677 2.677 0 0 1-.489 1.18l-.68.928a1.18 1.18 0 0 0 0 1.394l.68.927c.256.348.424.753.489 1.18l.174 1.137c.078.509.478.909.987.987l1.136.174a2.67 2.67 0 0 1 1.18.489l.928.68c.414.305.979.305 1.394 0l.927-.68a2.67 2.67 0 0 1 1.18-.489l1.137-.174a1.18 1.18 0 0 0 .987-.987l.174-1.136a2.67 2.67 0 0 1 .489-1.18l.68-.928a1.176 1.176 0 0 0 0-1.394l-.68-.927a2.686 2.686 0 0 1-.489-1.18l-.174-1.137a1.179 1.179 0 0 0-.987-.987l-1.136-.174a2.677 2.677 0 0 1-1.18-.489l-.928-.68a1.176 1.176 0 0 0-1.394 0ZM11.28 6.78l-3.75 3.75a.75.75 0 0 1-1.06 0L4.72 8.78a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L7 8.94l3.22-3.22a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042Z\"></path></svg> badge indicate GitHub has verified the creator of the action as a partner organization.\n   ![Screenshot of a workflow in the file editor. The sidebar shows Marketplace actions. A \"Creator verified by GitHub\" badge is outlined in orange.](/assets/images/help/repository/actions-marketplace-sidebar.png)\n\n## Adding an action to your workflow\n\nYou can add an action to your workflow by referencing the action in your workflow file. The actions you use in your workflow can be defined in:\n\n* The same repository as your workflow file\n* Any public repository\n* A published Docker container image on Docker Hub\n\nYou can view the actions referenced in your GitHub Actions workflows as dependencies in the dependency graph of the repository containing your workflows. For more information, see “[Dependency graph](/en/code-security/concepts/supply-chain-security/dependency-graph).”\n\n> \\[!NOTE]\n> To enhance security, GitHub Actions does not support redirects for actions or reusable workflows. This means that when the owner, name of an action's repository, or name of an action is changed, any workflows using that action with the previous name will fail.\n\n### Adding an action from GitHub Marketplace\n\nAn action's listing page includes the action's version and the workflow syntax required to use the action. To keep your workflow stable even when updates are made to an action, you can reference the version of the action to use by specifying the Git or Docker tag number in your workflow file.\n\n1. Navigate to the action you want to use in your workflow.\n2. Click to view the full marketplace listing for the action.\n3. Under \"Installation\", click <svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-copy\" aria-label=\"Copy to clipboard\" role=\"img\"><path d=\"M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25Z\"></path><path d=\"M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z\"></path></svg> to copy the workflow syntax.\n   ![Screenshot of the marketplace listing for an action. The \"Copy to clipboard\" icon for the action is highlighted with a dark orange outline.](/assets/images/help/repository/actions-sidebar-detailed-view.png)\n4. Paste the syntax as a new step in your workflow. For more information, see [Workflow syntax for GitHub Actions](/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idsteps).\n5. If the action requires you to provide inputs, set them in your workflow. For information on inputs an action might require, see [Using pre-written building blocks in your workflow](/en/actions/how-tos/write-workflows/choose-what-workflows-do/find-and-customize-actions#using-inputs-and-outputs-with-an-action).\n\nYou can also enable Dependabot version updates for the actions that you add to your workflow. For more information, see [Keeping your actions up to date with Dependabot](/en/code-security/how-tos/secure-your-supply-chain/secure-your-dependencies/auto-update-actions).\n\n### Adding an action from the same repository\n\nIf 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 GitHub Enterprise Server.\n\nExample repository file structure:\n\n```shell\n|-- hello-world (repository)\n|   |__ .github\n|       └── workflows\n|           └── my-first-workflow.yml\n|       └── actions\n|           |__ hello-world-action\n|               └── action.yml\n```\n\nWe 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 [Workflow syntax for GitHub Actions](/en/actions/reference/workflows-and-actions/workflow-syntax#example-using-an-action-in-the-same-repository-as-the-workflow-at-the-running-commit-recommended).\n\nExample workflow file using `$/`:\n\n```yaml\njobs:\n  my_first_job:\n    runs-on: ubuntu-latest\n    steps:\n      # This step references an action in the same repository at the\n      # running commit. No repository checkout is required.\n      - name: Use hello-world-action\n        uses: $/.github/actions/hello-world-action\n```\n\nYou 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.\n\nExample workflow file using `./`:\n\n```yaml\njobs:\n  my_first_job:\n    runs-on: ubuntu-latest\n    steps:\n      # This step checks out a copy of your repository.\n      - name: My first step - check out repository\n        uses: actions/checkout@v6\n      # This step references the directory that contains the action.\n      - name: Use local hello-world-action\n        uses: ./.github/actions/hello-world-action\n```\n\nThe `action.yml` file is used to provide metadata for the action. Learn about the content of this file in [Metadata syntax reference](/en/actions/reference/workflows-and-actions/metadata-syntax).\n\n### Adding an action from a different repository\n\nIf an action is defined in a different repository than your workflow file, you can reference the action with the `{owner}/{repo}@{ref}` syntax in your workflow file.\n\nThe action must be stored in a public repository.\n\n```yaml\njobs:\n  my_first_job:\n    steps:\n      - name: My first step\n        uses: actions/setup-node@v7\n```\n\n### Referencing a container on Docker Hub\n\nIf an action is defined in a published Docker container image on Docker Hub, you must reference the action with the `docker://{image}:{tag}` syntax in your workflow file. To protect your code and data, we strongly recommend you verify the integrity of the Docker container image from Docker Hub before using it in your workflow.\n\n```yaml\njobs:\n  my_first_job:\n    steps:\n      - name: My first step\n        uses: docker://alpine:3.8\n```\n\nFor some examples of Docker actions, see the [Docker-image.yml workflow](https://github.com/actions/starter-workflows/blob/main/ci/docker-image.yml) and [Creating a Docker container action](/en/actions/tutorials/use-containerized-services/create-a-docker-container-action).\n\n### Security hardening for using actions in your workflows\n\nGitHub provides security features that you can use to increase the security of your workflows. You can use GitHub's built-in features to ensure you are notified about vulnerabilities in the actions you consume, or to automate the process of keeping the actions in your workflows up to date. For more information, see [Secure use reference](/en/actions/reference/security/secure-use).\n\n## Using release management for your custom actions\n\nThe creators of a community action have the option to use tags, branches, or SHA values to manage releases of the action. Similar to any dependency, you should indicate the version of the action you'd like to use based on your comfort with automatically accepting updates to the action.\n\nYou will designate the version of the action in your workflow file. Check the action's documentation for information on their approach to release management, and to see which tag, branch, or SHA value to use.\n\n> \\[!NOTE]\n> We recommend that you use a SHA value when using third-party actions. However, it's important to note Dependabot will only create Dependabot alerts for vulnerable GitHub Actions that use semantic versioning. For more information, see [Secure use reference](/en/actions/reference/security/secure-use#using-third-party-actions) and [Dependabot alerts](/en/code-security/concepts/supply-chain-security/dependabot-alerts).\n\n### Using tags\n\nTags are useful for letting you decide when to switch between major and minor versions, but these are more ephemeral and can be moved or deleted by the maintainer. This example demonstrates how to target an action that's been tagged as `v1.0.1`:\n\n```yaml\nsteps:\n  - uses: actions/javascript-action@v1.0.1\n```\n\n### Using SHAs\n\nIf you need more reliable versioning, you should use the SHA value associated with the version of the action. SHAs are immutable and therefore more reliable than tags or branches. However, this approach means you will not automatically receive updates for an action, including important bug fixes and security updates. You must use a commit's full SHA value, and not an abbreviated value. When selecting a SHA, you should verify it is from the action's repository and not a repository fork. This example targets an action's SHA:\n\n```yaml\nsteps:\n  - uses: actions/javascript-action@a824008085750b8e136effc585c3cd6082bd575f\n```\n\n### Using branches\n\nSpecifying a target branch for the action means it will always run the version currently on that branch. This approach can create problems if an update to the branch includes breaking changes. This example targets a branch named `@main`:\n\n```yaml\nsteps:\n  - uses: actions/javascript-action@main\n```\n\nFor more information, see [Managing custom actions](/en/actions/how-tos/create-and-publish-actions/manage-custom-actions#using-release-management-for-actions).\n\n## Using inputs and outputs with an action\n\nAn action often accepts or requires inputs and generates outputs that you can use. For example, an action might require you to specify a path to a file, the name of a label, or other data it will use as part of the action processing.\n\nTo see the inputs and outputs of an action, check the `action.yml` in the root directory of the repository.\n\nIn this example `action.yml`, the `inputs` keyword defines a required input called `file-path`, and includes a default value that will be used if none is specified. The `outputs` keyword defines an output called `results-file`, which tells you where to locate the results.\n\n```yaml\nname: \"Example\"\ndescription: \"Receives file and generates output\"\ninputs:\n  file-path: # id of input\n    description: \"Path to test script\"\n    required: true\n    default: \"test-file.js\"\noutputs:\n  results-file: # id of output\n    description: \"Path to results file\"\n```"}