CloudBees action: Promote an image in Amazon ECR

2 minute read

Use this action to promote (copy) an image in Amazon Elastic Container Registry (Amazon ECR). This action also reports artifact-related data to the workflow run for artifact traceability purposes.

All CloudBees action repositories are listed at CloudBees, Inc. on GitHub.

Inputs

Table 1. Input details
Input name Data type Required? Description

registry-url

String

Yes

The Amazon ECR registry URL.

source-repository-name

String

Yes

The Amazon ECR source repository name.

source-tag

String

Yes

The Amazon ECR source image tag.

target-repository-name

String

Required only if target-tag is identical to source-tag.

The Amazon ECR target repository name.

target-tag

String

Required only if the target-repository-name is identical to the source-repository-name.

The Amazon ECR target image tag.

Outputs

Table 2. Output details
Output name Data type Description

artifact-id

String

The unique identifier of the artifact reported to the CloudBees platform.

Usage examples

Basic example

The following is a basic example of using this action:

- name: Promote an image in ECR uses: cloudbees-io/ecr-promote-image@v1 with: registry-url: ${{ vars.EC_REGISTRY_URL }} source-repository-name: my-ecr-repo-name source-tag: 6

Using optional inputs

The following example specifies the target-repository-name, required in this case because the source and target tags are identical:

- name: Promote an image in ECR uses: cloudbees-io/ecr-promote-image@v1 with: registry-url: ${{ vars.REGISTRY_URL }} source-repository-name: my-source-repo-name source-tag: 2 target-repository-name: my-target-repo-name target-tag: 2

Full workflow example

The following workflow example:

  • Checks out source code from a repository.

  • Promotes an image from a remote Amazon ECR repository to another Amazon ECR repository.

  • Prints the artifact ID of the promoted file.

nname: ecr-promote-image kind: workflow apiVersion: automation.cloudbees.io/v1alpha1 on: push: branches: - main jobs: ec2-promote-image-job: steps: - name: Configure AWS credentials uses: cloudbees-io/configure-aws-credentials@v1 with: aws-region: us-west-1 aws-access-key-id: ${{ secrets.MY_AWS_KEY_ID }} aws-secret-access-key: ${{ secrets.MY_AWS_ACCESS_KEY }} - name: ECR promote image id: ecr-promote uses: cloudbees-io/ecr-promote-image@v1 with: registry-url: 123456789012.dkr.ecr.us-west-1.amazonaws.com source-repository-name: my-repo-name source-tag: ABC-1234-567a890b1234567890bcde1234567890abcde123 target-tag: my-target-tag - name: Print output parameter artifact ID from ECR pro mote action uses: docker://alpine:latest shell: sh run: | echo "artifact ID for the artifact my-repo-name:my-target-tag is: ${{ steps.ecr-promote.outputs.artifact-id }}"