Build an end-to-end GHA workflow with CloudBees Unify

2 minute read

In this tutorial, you build a GHA workflow that performs the following tasks and displays the results in the CloudBees Unify UI:

Prerequisites

Set up CloudBees Unify and GHA to work together, providing key features of CloudBees Unify to GHA workflows. For more information, refer to Set up GitHub Actions integration.

Create the workflow

Add the following workflow YAML file to the GitHub repository connected to CloudBees Unify.

Example GHA workflow YAML file
name: GHA workflow on: workflow_dispatch: jobs: build: runs-on: ubuntu-latest steps: - name: Compile code run: echo "Compiling..." - name: Produce binary run: sleep 5 - name: Push binary run: echo "Pushing Binary to ECR..." - name: Register build artifacts in Cloudbees platform uses: cloudbees-io-gha/register-build-artifact@v1 id: go-action with: name: "GHA App" version: 1.0.5 url: docker.io/MyApp/GHA App:1.0.5 digest: "sha256:1234567890abcdef1234abcdef12ab3456ab7890abcd1234bcdef1234abcd123" type: "docker" cloudbees-pat: ${{ secrets.CBP_PAT }} - name: Publish evidence uses: cloudbees-io-gha/publish-evidence-item@v1 with: cloudbees-pat: ${{ secrets.CBP_PAT }} content: |- Build Completed and artifacts published to Cloudbees platform test: runs-on: ubuntu-latest needs: [build] # Depends on 'build' job steps: - name: Run tests run: echo "Running Tests..." - name: Checkout to collect test results uses: actions/checkout@v3 - name: Publish test results in Cloudbees platform uses: cloudbees-io-gha/publish-test-results@v1 with: test-type: GO folder-path: test_reports/* cloudbees-pat: ${{ secrets.CBP_PAT }} - name: Publish evidence in Cloudbees platform uses: cloudbees-io-gha/publish-evidence-item@v1 with: cloudbees-pat: ${{ secrets.CBP_PAT }} content: |- Testing Completed and results published to Cloudbees platform Test | Results | --------|---------| Test 1 | PASS | Test 2 | FAIL | Test 3 | PASS | deploy: runs-on: ubuntu-latest needs: [build, test] # Depends on both 'build' and 'test' jobs steps: - name: Checkout to prepare manifest uses: actions/checkout@v3 - name: Trigger deployment uses: cloudbees-io-gha/run-cloudbees-workflow@v1 id: deploy with : cloudbees-pat: ${{ secrets.CBP_PAT }} workflow-file-name: "deploy.yaml" workflow-inputs: '{"artifactName": "GHA App","artifactVersion": "1.0.5", "environment": "qa"}' - name: Use runUrl output run: echo "The CloudBees run URL is ${{ steps.deploy.outputs.cbp_run_url}}"
▼

Run the workflow and review the results

After the run has completed, the:

  • Artifact information is displayed in both Components  Artifacts and Run details  Build artifacts in CloudBees Unify.

    Artifact displayed
    Figure 1. Artifact displayed in CloudBees Unify.
  • Evidence output is collected and displayed in the Evidence tab of Run details.

    Build evidence displayed
    Figure 2. Evidence from build job displayed in CloudBees Unify.
    Test evidence displayed
    Figure 3. Evidence from test job displayed in CloudBees Unify.
  • Testing results are collected and displayed in the Test results tab of Run details and in the Test insights dashboard.

    Test results displayed
    Figure 4. Testing results from test job displayed in CloudBees Unify.
  • CloudBees Unify workflow run is triggered by the GHA workflow and the workflow output is published in the job evidence.

    Deploy evidence displayed
    Figure 5. Resulting CloudBees Unify workflow run output.