|
A single workflow job must contain only one of the following execution syntax terms: |
Specify an action with uses
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, branch name, or 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 stepuses an action from a public repository with the commit SHA specified. -
The
Second stepuses a CloudBees platform action with the major version tag specified. -
The
Third stepuses themainbranch of a subdirectory in a public GitHub repository.
steps: - name: First step uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - name: Second step uses: https://github.com/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: https://github.com/cloudbees-io/checkout@v1 - name: Use local action uses: ./.github/actions/my-action
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 https://github.com/cloudbees-io/checkout).
In your workflows, you can also use composite actions that invoke other actions, either from a dedicated GitHub repository or a local relative path.
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, whether from the workflow or any action it uses, are resolved to the repository where the workflow resides.
Specify a Docker image with uses
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 stepspecifies thealpine:3.8image. -
The
Second stepspecifies a public Docker image in the Google Container Registry atgcr.io.
jobs: my-job: steps: - name: First step uses: docker://alpine:3.8 - name: Second step uses: docker://gcr.io/cloud-builders/gradle