GitHub Action: Register a deployed artifact in CloudBees Unify

2 minute read

Use this GitHub Action (GHA) for deployment traceability: inform CloudBees Unify that an artifact version has been deployed to an environment. This enables DORA metrics, environment inventory tracking, and deployment analytics for artifacts deployed through GHA workflows.

This action is available on the GitHub marketplace.

To learn more about working with artifacts in CloudBees Unify, refer to the build artifacts documentation.

Prerequisites

Set up CloudBees Unify and GHA to work together, providing key features of CloudBees Unify to GHA workflows. Refer to Getting started for more information.

Inputs

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

cloudbees-url

String

No

URL of the CloudBees Unify API. Defaults to https://api.cloudbees.io.

target-environment

String

Yes

Deployment environment. You must create the environment in CloudBees Unify before using it in this action.

labels

String

No

Comma-separated labels for this deployment.

artifact-id

String

No

ID of the artifact, generated by the register-build-artifact action. Either this or artifact-url must be present.

artifact-url

String

No

URL of the deployed artifact. Either this or artifact-id must be present.

Outputs

This action produces no output.

This version of the action uses GitHub OIDC authentication to securely communicate with CloudBees Unify. Be sure to set permissions to id-token: write in your workflow.

Usage examples

The following is a basic example of using the action:

permissions: id-token: write contents: read steps: - name: register-deployment-step uses: cloudbees-io-gha/register-deployed-artifact with: target-environment: production labels: latest artifact-id: 87ace777-ab20-4867-ac3f-ad5c28f46a29

The following example uses the artifact URL instead of the artifact ID:

permissions: id-token: write contents: read steps: - name: register-deployment-step uses: cloudbees-io-gha/register-deployed-artifact with: target-environment: production artifact-url: https://hub.docker.com/repository/docker/example

Full workflow and run example

Running this workflow creates an artifact that is reported to CloudBees Unify, and then that artifact is deployed.

Example GHA workflow YAML file
name: GHA Workflow on: - workflow_dispatch jobs: build-deploy: runs-on: ubuntu-latest permissions: id-token: write contents: read steps: - name: Compile Code run: echo "Compiling..." - name: Produce Binary run: echo "Generating binary..." - name: Push binary run: echo "Pushing Binary to ECR..." - name: Register Build Artifacts in CloudBees Unify uses: cloudbees-io-gha/register-build-artifact@v3 id: go-action with: name: "gha-artifact-step" version: 1.0.0 url: "docker.io/example:latest" digest: sha256:1234567890abcdef123456123456abcdef789078907890abcdefabcdef123456 label: For testing type: docker - name: Deploy artifact run: echo 'Deploying Build ArtifactId ${{ steps.go-action.outputs.cbp_artifact_id }}' - name: Register deployment uses: cloudbees-io-gha/register-deployed-artifact with: target-environment: production labels: latest artifact-id: ${{ steps.go-action.outputs.cbp_artifact_id }}

After the run completes, the artifact information is displayed in the Run details  Deployments tab in CloudBees Unify.