Making a Code Change and Triggering the Continuous Integration (CI) Process

Nice work on getting the application deployed on OpenShift! Now you’ll make a change to the application’s development environment configuration, verify it passes CI, merge the change into the main branch and watch as Argo CD detects and applies the new change.

  1. Head over to your copy of the random-meme application repository: github.com/%USERID%/rht-summit-2023-sample-application.

  2. Use the period/dot key as a shortcut to open the GitHub IDE.

  3. Once the GitHub IDE has loaded:

    • Click the branch name (main by default) in the bottom left.

    • Select Create new branch in the popup that appears.

    • Enter the follwoing branch name and press the enter key: new-meme

    • Click the green Switch to branch button when promoted.

  4. Use the following image as a guide for completing the prior steps:

    ex8.gh new branch

  5. Add a new image to the k8s/overlays/development/config-map.yaml file. You can use the URL of any image that you like.

    The URL of the image must resolve to an image file, and not a page that contains the image. If the URL ends in an extension such as .png or .jpg then it’ll likely resolve directly to an image.

  6. Select the Source Control view from the side-menu.

  7. Enter a commit message and push your change using the Commit & Push button.

    ex8.gh diff commit

This new branch can be used to create a pull request. Creating the pull request will invoke a CI process, after which the code change can be merged to the main branch.

It’s common to use a trunk-based development model with Argo CD. That’s why your pull request will target the main branch, and not a development or staging branch. The k8s/overlays directory contains a unique configuration for each environment. Since the application is containerised, each of the k8s/overlays (i.e environments) can be updated to point to a specific container image tag. This alleviates the need to have branches with varying configurations that result in tedious Git merges at a later point in time.

  1. Return to your copy random-meme application repository.

  2. It should display a message that your new-meme branch had changes, and it suggests opening a pull request.

    ex8.gh pr notice

  3. Click on the Compare & pull request button.

  4. On the Open a pull request screen, scroll down and click the Create pull request button.

  5. Approve the pending checks if prompted, then wait for them to complete.

  6. Do not merge the pull request yet!

    ex8.gh pr open

If the CI check fails, it most likely means that a URL you added to the ConfigMap doesn’t resolve to an image or there’s a syntax error in the JSON array in the ConfigMap. Make sure that your chosen URL returns an image and not a page that contains an image since that will fail the CI check. Another thing to be aware of is to make sure the image URL in the ConfigMap is surrounded by quotes, and that you haven’t misplaced a comma.

Once the CI checks have passed move on to the next section.