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.

  • For any CloudBees action, you must include the major version tags.

  • With other actions, you must include the version, in the form of a Git ref, SHA, or Docker tag.

Some actions require inputs that you must set using the with keyword. This information is detailed in the README file of the action.

Actions are either JavaScript files or Docker containers. If the action you’re using is a Docker container 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