Preparing the GitHub Workflow
Last updated
Last updated
To trigger a workflow in GitHub CI/CD, a special yml
script to invoke the container must be inserted into the project’s repository. This script MUST be placed in the .github
directory at the top level of the repository. If it is not already present, a subdirectory named workflows
must be created. Then, within the workflows
directory, a yml
script describing the bahviour of the workflow is placed. This script is triggered upon events specified in the script.
OpenRefactory supplies a sample script for use with GitHub CI/CD. It triggers upon the occurrence of push or pull requests but the DevOps engineer preparing the workflow can create whatever triggers are appropriate for their specific needs. This script can be incorporated into a previous workflow script or edited to make the workflow operate as needed.
We won’t cover how to add a file to a GitHub repository as that is beyond the scope of this User Guide.
For our example, we are using the baritone
project. We go to the main repository page for this project and look at the .github/workflows
directory:
We have copied the sample githubAction.yml
script there. Let’s quickly review the sample script:
In this sample script, the on:
section specifies what will trigger the execution of this script. In this example, whenever a commit is pushed to the master
branch, it will be executed. The registry where the package is registered is identified as ghcr.io
as specified in the GitHub documentation. If you are using GitHub Enterprise, then the registry will be the URL of your local GitHub Enterprise server. For items such as the User ID for the user for whom this workflow is to be executed, subsitute <User_ID>
with that User's login ID.
The critical items of interest are the variables referenced in the run:
step. They are needed to be able to locate the targeted iCR server and to provide the Navigator with the information required so it can authenticate itself with the proper username and identify the project and branch name.
There are seven variables in the script. Let’s look at all of them. They are broken into 2 groups: preconfigured environment variables and user supplied secret values.