This repository illustrates the use of CloudBees CD/RO GitHub Actions in your GitHub Action Workflows to deploy and release applications. This repository includes is the code and Dockerfile needed to build a very simple deployable application. The repository also includes workflows to set up a CloudBees CD/RO instance and perform deployments and releases to the Kubernetes cluster where the CloudBees CD/RO instance is running.
- A CloudBees CD/RO instance with the appropriate port (443) reachable by the GitHub runners so that it can accept REST API calls
- An API token from the CloudBees CD/RO instance (see Manage access tokens via the UI documentation)
- A read/write repo+packages GitHub API token (see Personal Access Tokens)
- A Docker hub API token (Log into https://hub.docker.com/ and navigate to account settings > Security and generate a read/write token)
Most of the CloudBees CD/RO instance setup is handled through the demonstration repository automation. It may be necessary to update a property value so that the deployed application can be easily accessed through a job link.
- Open and login to the CloudBees CD/RO user interface from a web browser
- From the left hand menu, navigate to Administration > Server Properties
- Examine the value set for
app_base_hostname
- If this does not matches your CloudBees CD/RO hostname, edit the property to make it so. The edit command is available from the right hand menu.
- Alternatively, you can set this property through the DSL IDE. Navigate to the DSL IDE from the left hand menu under DevOps Essentials, copy the text
property "/server/app_base_hostname", value: "gha.cb-demos.io"
to the editor, replacinggha.cb-demos.io
with your instance's FQDN hostname, then press the green button to the right to apply the DSL code.
- Navigate to the demonstration repository, https://github.com/cloudbees-demos/gh-actions-demo
- Press the "Use this template" button to create a new repository in an organization you have write access to
- Navigate to Settings > Secrets and variables > Actions and add the following repository secrets:
CDRO_URL
, for example, https://my-cdro-server.example.comCDRO_TOKEN
DOCKERHUB_USER
DOCKERHUB_TOKEN
GH_PAT
- Navigate to the Actions tab
- Run the "Setup and CD config" Action using the "Run workflow" dropdown button
- Once that Action is completed, run the “Build and Deploy” to initialize the application in the
demo-dev
environment Steps 1-6 can be scripted. You'll need the GitHub command line tool,gl
(See https://cli.github.com/). Edit the repository file GitHubSetup.sh with your values and run the script from a shell that has been authenticated to GitHub.
At this point, CloudBees CD/RO should have deployed the application to the demo-dev
environment (demo-dev
namespace in the CloudBees CD/RO Kubernetes Instance). Navigate to the application run to see the results:
- Using the left-hand navigation menu, select Deployment Automation > Applications
- There, you should see the Application model "Demo App", select the link to view the model
- Select the "Application process run" tab to view a listing of deployments, select the deployment link
- Note in the upper right corner, there are two links
- Demo App - This like will take you to the
demo-dev
-deployed application - GitHub Action Workflow URL - This will take you to the workflow run that kicked off this deployment
- Using the left-hand navigation menu, select Deployment Automation > Environment Inventory to view details about what was deployed, namely the image
demo
and its version to thedemo-dev
environment. - Using the left-hand navigation menu, select Analytics > Dashboards > Application Deployments to view the deployment report
If a change is made and pushed to the repository, the workflow will rebuild the application image, and a CloudBees CD/RO Release will be initiated to manage the staged release to
demo-prod
. - Edit the README.md file by adding a blank line, for example, and commit to
main
. This should start the “Build and Deploy” workflow again, but this time it will create a release model and start it with the new application image. - Using the left-hand navigation menu, select Release Orchestration > Releases
- There you should see a Release model called "Simple Release ", select the link to view the model
- Select the Pipeline runs tab to view the Release Pipeline run
- Once the first stage has been completed, it is ready for approval to promote the application to
demo-prod.
- Refresh the application window to see the newly deployed version of the application
- Go ahead to approve the manual task.
- Select the Path to product to view the status of the release artifacts
- Once the
demo-prod
deployment has been completed, examine the Environment Inventory once again - You can navigate to the
demo-prod
deployment through the Release Pipeline run Production stage deployment task; there, you can view the newly deployed application indemo-prod
.
- Secrets added to the repository according to the instructions above will be pushed to and used by the CloudBees CD/RO instance to establish authenticated sessions with Docker Hub and GitHub. The secret values are managed as credentials in CloudBees CD/RO. Credentials are encrypted before they are stored in the system. However, users with sufficient access rights on the system can retrieve the credential values.
- By default, SSL certificated are ignored to support self-signed certificate CloudBees CD/RO instances. If this is not desired, update the files cd-setup.yaml and build-and-deploy.yml, replacing "true" with false in all the
ignore-unverified-cert
fields.
Demo for SAs 2