jobs.<job_id>.steps[*].uses

2 minute read

uses with actions

Use jobs.<job_id>.steps[*].uses to add an action to run in your step. For more information, refer to CloudBees actions.

You can use an action defined in the same repository as the workflow, a public repository, or in a published Docker container image.

CloudBees strongly recommends that you specify the version with any action you use, to avoid any broken workflows or other unexpected behavior. The version may be in the form of a Git tag, a branch name, or a commit SHA.

Some actions require inputs that you must set using the with keyword. This information is detailed in the action documentation. Actions are Docker containers (not Dockerfile actions), and you must run the job in a Linux environment.

Example usage

{owner}/{repo}@{ref}

In the following example:

  • The First step uses an action from a public repository with the commit SHA specified.

  • The Second step uses a CloudBees action with the major version tag specified.

  • The Third step uses the main branch of a subdirectory in a public GitHub repository.

steps: - name: First step uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - name: Second step uses: cloudbees-io/kaniko@v1 - name: Third step uses: actions/aws/ec2@main

If the action is in the same repository as the workflow, you must first check out your repository, as in the following example:

jobs: my-job: steps: - name: Check out repository uses: cloudbees-io/checkout@v1 - name: Use local action uses: ./.github/actions/my-action

uses with images

Use jobs.<job_id>.steps[*].uses to add a Docker image published on Docker Hub to your step.

docker://{image}:{tag}

In the case of a hosted image:

docker://{host}/{image}:{tag}

Example usage

In the following example:

  • The First step specifies the alpine:3.8 image.

  • The Second step specifies a public Docker image in the Google Container Registry at gcr.io.

  • The Third step .

jobs: my-job: steps: - name: First step uses: docker://alpine:3.8 - name: Second step uses: docker://gcr.io/cloud-builders/gradle

Action contexts

The platform allows you to invoke actions defined in a repository using their relative path (for example, uses: ./local-action), instead of fetching them from a dedicated repository (such as cloudbees-io/checkout).

Local scan action
Figure 1. Scan 2, highlighted, uses a local child action.

In your workflows, you can also use composite actions that invoke other actions, either from a dedicated GitHub repository or a local relative path.

Composite action
Figure 2. A composite action referring to a different repository is highlighted.

If a composite action refers to another action in the same repository by using a local action link (uses: ./local-action), then the workflow that uses this action fails, unless it also resides in the same repository.

All local references, either from the workflow itself or any action used by the workflow, are resolved to the repository where the workflow resides.