How to setup GitHub Actions Pipeline
GitHub Actions gives you the ability to create workflows to automate the deployment process to OpenShift. GitHub Actions makes it easy to automate all your CI/CD workflows.
Terminiology
Workflow
Automation-as-code that you can set up in your repository.
Events
30+ workflow triggers, including on schedule and from external systems.
Actions
Community-powered units of work that you can use as steps to create a job in a workflow.
Deploy an Application to your NERC OpenShift Project
-
Prerequisites
You must have at least one active NERC-OCP (OpenShift) type resource allocation. You can refer to this documentation on how to get allocation and request "NERC-OCP (OpenShift)" type resource allocations.
Steps
-
Access to the NERC's OpenShift Container Platform at https://console.apps.shift.nerc.mghpcc.org as described here. To get access to NERC's OCP web console you need to be part of ColdFront's active allocation.
-
Setup the OpenShift CLI Tools locally and configure the OpenShift CLI to enable
oc
commands. Refer to this user guide. -
Setup Github CLI on your local machine as described here and verify you are able to run
gh
commands as shown below: -
Fork the
simple-node-app
App in your own Github:This application runs a simple node.js server and serves up some static routes with some static responses. This demo shows a simple container based app can easily be bootstrapped onto your NERC OpenShift project space.
Very Important Information
As you won't have full access to this repository, we recommend first forking the repository on your own GitHub account. So, you'll need to update all references to
https://github.com/nerc-project/simple-node-app.git
to point to your own forked repository.To create a fork of the example
simple-node-app
repository:-
Cick the "Fork" button to create a fork in your own GitHub account, e.g. "
https://github.com/<github_username>/simple-node-app
".
-
Clone the simple-node-app git repository:
git clone https://github.com/
/simple-node-app.git cd simple-node-app -
Run either
setsecret.cmd
file if you are using Windows orsetsecret.sh
file if you are using Linux based machine. Once executed, verify Github Secrets are set Properly under your github repo's settings >> secrets and variables >> Actions as shown here: -
Enable and Update GitHub Actions Pipeline on your own forked repo:
-
Enable the OpenShift Workflow in the Actions tab of in your GitHub repository.
-
Update the provided sample OpenShift workflow YAML file i.e.
openshift.yml
, which is located at "https://github.com/<github_username>/simple-node-app/actions/workflows/openshift.yml
".Very Important Information
Workflow execution on OpenShift pipelines follows these steps:
- Checkout your repository
- Perform a container image build
- Push the built image to the GitHub Container Registry (GHCR) or your preferred Registry
- Log in to your NERC OpenShift cluster's project space
- Create an OpenShift app from the image and expose it to the internet
-
-
Edit the top-level 'env' section as marked with '🖊️' if the defaults are not suitable for your project.
-
(Optional) Edit the build-image step to build your project:
The default build type uses a Dockerfile at the root of the repository, but can be replaced with a different file, a source-to-image build, or a step-by-step buildah build.
-
Commit and push the workflow file to your default branch to trigger a workflow run as shown below:
-
Verify that you can see the newly deployed application on the NERC's OpenShift Container Platform at https://console.apps.shift.nerc.mghpcc.org as described here, and ensure that it can be browsed properly.
That's it! Every time you commit changes to your GitHub repo, GitHub Actions will trigger your configured Pipeline, which will ultimately deploy your application to your own NERC OpenShift Project.