Promotion using GitHub Actions
By leveraging the functionality of GitHub Actions, promoting code changes from one environment to another is as easy as committing/pushing your code and opening/merging pull requests. This example project contains three GitHub Actions (in the./.github/workflows directory) that perform the following:
- On a pull request (or updates to an existing pull request) to the
mainbranch, the application is containerized and pushed to the dev Org’s private image registry. The GVC andReview Workloadis created/updated by applying the YAML contents of the files./cpln/cpln-gvc.yamland./cpln/cpln-workload.yaml. The name of theReview Workloadwill be prefixed by the name of the branch that created the pull request. - When a pull request is accepted and the code is merged to the
mainbranch, adevworkload is updated (or created if it doesn’t exists) in the dev Org by applying the same files as step 1, except that the workload name is prefixed withdev. This allows the application to be reviewed and tested before being pushed to the production Org. - The promotion to the
stageandprodenvironment is accomplished by manually executing theDeploy-To-Stage-or-Prodworkflow and selecting the target environment. The target GVC and Workload in the production Org is updated (or created if it doesn’t exists) by applying the YAML contents of the files./cpln/cpln-gvc-prod.yamland./cpln/cpln-workload.yaml. The main difference between the two GVC files is that theprodversion contains thePull Secretthat is needed to pull the image from the dev Org and thestageandprodworkloads refer to the image that was pushed to the development Org.
Review Workload
The above example demonstrates the concept of a Review Workload. This workload allows for review and testing of the application before being promoted to upstream workloads. The deployment of the Review Workload occurs when a pull request from a feature branch to themain branch is opened. The application will only be promoted to the dev workload if the pull request is closed and merged.
Permissions
To control which users have the ability to perform sensitive actions, such as merging a pull request, you can utilize the built-in capabilities of GitHub by creating a custom repository role. Review these instructions on how to create a role.Notes
- The example above demonstrates promoting code across four environments (review and development in one Org, and staging and production in a separate Org). Of course, you can arrange each environment within its own Org, or mix multiple environments within an Org as shown in the example. There is no limit to the number of Orgs / environments that can be created. This example can be adapted to suit your unique deployment requirements.
- For more complex applications, each environment’s GVC / workload should be configured with its own: