Integrating Git to Code Pipeline for GitHub Actions
This topic describes in detail, all the tasks that you need to perform to synchronize Git and Code Pipeline when you are using the GitHub Actions orchestrators.
Task 1: Setting up the environment
This step provides you with instructions to install the required plugins and other configuration.
- Install EGit. For more information on the installation process, see Egit download manual.
Configure GitHub Self-hosted runner.
You can install the runner on a virtual machine or on your own machine. There are 3 levels of a self-hosted runner.- Repository-level runners are dedicated to a single repository.
- Organization-level runners can process jobs for multiple repositories in an organization.
- Enterprise-level runners can be assigned to multiple organizations in an enterprise account.
To configure the GitHub Self-hosted runner, perform the following steps:
Create the necessary environment before you run the steps for creating a self-hosted runner.
- For an organization-level self-hosted runner, create an organization if one does not already exist.
- For a repository-level self-hosted runner, create a new repository through GitHub, or you may simply use an existing repository if you already have one created.
- In GitHub, navigate to the settings page that will allow you to create a self-hosted runner. You can find this page by going into the settings of your organization/repository and clicking on the Actions menu option within the settings.
- Go to the bottom of the page and find the Self-hosted runners section.
- Select the Add new option > New runner for an Organization > New runner for a Repository.
You will be redirected to a new page that mentions all the steps for creating a runner. Before you perform any of the steps, make sure you select the Operating System of the machine on which you will host the runner. The following steps described below are for Windows VM, but the steps are similar to any other OS.
Run the commands provided on the page using the appropriate shell for your OS.
Start the PowerShell the run as administrator option within Windows. You might need to download PowerShell for Windows from Github (run the .msi in Github from https://github.com/PowerShell/PowerShell/releases/tag/v7.1.3) or bash shell for Linux. When prompted if you want the runner to run as a service, enter Yes, so that you do not have to manually start each time. Alternately, go to the actions-runner location and run the run.cmd.
- After running the steps within your shell, the shell should look like:
- To confirm if the runner is installed successfully for a Windows VM once the process is completed, go to Start Menu >Your services> search GitHub Actions Runner. If you see the runner, it means the runner has been configured and is running.
- Complete Extra Setup for Code Pipeline Synchronization
Setup if using the ispw-sync GitHub Docker action:
To use ispw-sync Docker container action, self-hosted runner must use a Linux operating system and have Docker installed. GitHub only supports Linux self-hosted runner for Docker container action. A WorkbenchCLI Docker image is distributed from Docker hub and you do not need to install WorkbenchCLI on the self-hosted runner.
If an Ubuntu based self-hosted runner is preferred, run the following commands. For more information, see Install Docker Engine on Ubuntu article on docker docs.
$ sudo apt-get remove docker docker-engine docker.io containerd runc
$ sudo apt-get update
$ sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg \
lsb-release
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
$ echo \
"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
$ sudo apt-get update
$ sudo apt-get install docker-ce docker-ce-cli containerd.ioAs the action-runner cannot run under root, the action-runner will have the following error to trigger any docker action:
Got permission denied while trying to connect to the Docker daemon socketTo resolve the issue, modify the permission and restart Docker daemon:
$ sudo usermod -aG docker ${USER}
$ sudo rm -rf ~/.docker
$ sudo systemctl restart docker
$ sudo chmod 666 /var/run/docker.sock- Setup if using the ispw-sync-local GitHub action:
- For Windows based self-hosted runner, install the WorkbenchCLI windows distribution.
- For Linux based self-hosted runner, install the WorkbenchCLI Linux distribution.
Task 2: Verifying if the Code Pipeline mainframe PLAY application is available
The Code Pipeline PLAY application is installed as a part of the Training Application delivered in the Code Pipeline SAMPLIB in the Installation Verification Process (IVP).
Perform the following steps to install the PLAY application instance based on your host connection. If you are unable to locate the PLAY application, refer Installation Verification Procedures in the Code Pipeline Installation and Configuration guide.
- In Workbench for Eclipse, open the Code Pipeline perspective.
- From the Window menu, select Open Perspective>Other. The Open Perspective dialog box appears.
Select Code Pipeline and click OK. The Code Pipeline Repository Explorer view appears.
- In the Code Pipeline Repository Explorer select the following:
- From the Stream list, select PLAY.
- From the Application list, select PLAY.
- From the Sub-Application list, select PLAY.
- From the Level list, select DEV1.
- From the Level option list, select First found in level and above.
Click Apply. A filtered list of the components within the PLAY application appears.
Task 3: Setting up a GitHub repository with the Code Pipeline source and YAML configuration file
To create a new GitHub repository named GitPlay, perform the following steps:
- Go to the GitHub.
- To create a personal repository, select Your repositories from profile, then select New.
- Make sure Add a README file is checked, so the repository is fully initialized.
Task 4: Cloning the GitPlay repository from GitHub and importing as an Eclipse project
- In Workbench for Eclipse, open the Git perspective.
- Clone the GitPlay repository.
- Import the repository as standard Eclipse project once the repository is cloned successfully,
Task 5: Configuring Code Pipeline and importing the Code Pipeline source
In Workbench for Eclipse’s Project Explorer view, right-click the GitPlay project node and select Configure>Configure to Use
Code Pipeline
. The Configure
Code Pipeline
and GIT Mapping wizard appears.
- From the Host list, select the host where the PLAY application is located, or click Configure to configure a host. We recommend using the fully qualified domain name when configuring the host.
- In the Runtime Configuration field, enter the runtime configuration if not using the default Code Pipelineinstance.
- Click Next. The next page of the wizard appears.
- From the Stream list, select PLAY.
- From the Application list, select PLAY.
- From the Sub-Application list, select PLAY.
- From the Level list, select the level used when doing a build.
- From the Download source from path list, choose the level from which to download source for the project.
- In the YAML mapping file location field, enter or browse to the project folder in which to create the YAML mapping file. By default, the location is the root of project.
- Click Finish. The source is downloaded. The ispwconfig.yml file is created and added to the root of the GitPlay project in the Project Explorer view. The Console view shows the activity, and the Project Explorer view shows the downloaded files.
To examine the contents of the ispwconfig.yml file, right-click the file and select Open.
!!com.compuware.ispw.cli.model.IspwRoot
ispwApplication:
application: PLAY
host: somehost.example.com
pathMappings:
- path: \CLST
types:
- fileExtension: clst
ispwType: CLST
- path: \COB
types:
- fileExtension: cob
ispwType: COB
- path: \COPY
types:
- fileExtension: copy
ispwType: COPY
- path: \JOB
types:
- fileExtension: job
ispwType: JOB
port: 12345
runtimeConfig: TPZP
stream: PLAY- For information on the available Code Pipelineproperty settings and path mappings, see Git-to-Code-Pipeline-integration-the-Code-Pipeline-YAML-configuration-file.
Task 6: Committing and Push the GitPlay project to the Master branch in the GitPlay repository
- In Workbench for Eclipse, open the Git perspective.
- If the Git Staging view is not visible, from the Window menu, select Show View>Other. The Show View dialog box appears. Select Git>Git Staging, and click Open.
- If there is no repository selected in the Git Staging view, click
and select GitPlay to switch to the GitPlay repository.
- In the Unstaged Changes box, select all of the components and click
to add them to the Staged Changes box.
- In the Commit Message box, enter a commit message, such as Commit to master.
- Click Commit and Push.
- If the Push Branch master dialog box appears, in the URI field, specify the URL of the GitPlay repository. The repository URL can be found in the Git server Repository Settings of the GitPlay repository under the Name field. Complete the rest of the fields if not automatically populated. Click Next to select the remote repository. The repository name should contain the branch name. Click Next again to confirm the expected push result, then click Finish.
- In the Push Results dialog, click Close.
Task 7: Creating a GitHub workflow
- In Project Explorer View, select Filters and Customization..., then uncheck .*resources to show hidden files and folders for the GitPlay project.
- Expand GitPlay project, create folder .github/workflows.
- Create a GitHub workflow file, for example, ispw-sync-build-deploy.yml (Download a template), the workflow is broken up into the following stages:
- Checkout - checks out the source code.
- Synchronize changeset to Code Pipeline - uses GitHub action ispw-sync to perform GitHub to Code Pipeline synchronization.
- Build Code Pipeline tasks - uses GitHub action ispw-build to perform a build.
Deploy Code Pipeline tasks - uses gitHub action ispw-deploy to perform a deploy.
Or if you prefer to use GitHub action ispw-sync-local, you may specify the sync step as below, the workflow is broken up into the following stages (Download a template - ispw-sync-local-generate-deploy.yml):
- Checkout - checks out the source code.
- Synchronize changeset to Code Pipeline - uses GitHub action ispw-sync-local to perform GitHub to Code Pipeline synchronization.
- Generate Code Pipeline tasks - uses GitHub action ispw-generate to perform a generate.
- Deploy Code Pipeline tasks - uses GitHub action ispw-deploy to perform a deploy.
- Create secrets to hide usernames, passwords, or tokens that will be used in the workflows.
- Navigate to your GitHub repository where your workflows are stored.
- Click on the Settings tab that is located on the top left just under the repository path.
- Click on the Secrets section.
- From the following screen, you can either create organization level secrets (secrets that can be used across all repositories within your organization group) or repository level secrets.
Some secrets examples you may create based on the ispw-sync-build-deploy.yml (Download a template) are as follows:
- secrets.TSOUSER
- secrets.TSOPASS
- secrets.GITUID
- secrets.GITHUB_TOKEN
- secrets.CES_TOKEN
Task 8: Making a change and building
To make a change to Cobol component TPROG15.cob, perform the following steps:
- In Workbench for Eclipse’s Project Explorer view, expand GitPlay>COB.
- Right-click TPROG15.cob and select Open. The source opens in the editor.
- On line 8, append the TEST to ...PROGRAM.
- From the File menu, select Save.
- From the File menu, select Close.
Task 9: Performing the build action to verify the source generates successfully along with any impacted components
In Workbench for Eclipse’s Project Explorer view, Right click GitPlay project, select Properties, add
Code Pipeline
Nature, then click Apply and Close.
In Workbench for Eclipse’s Project Explorer view, right-click the GitPlay project node and select Properties>Code Pipeline
. The
Code Pipeline
page of the Properties dialog box appears.
- In the YAML mapping file location field, enter or browse to the YAML mapping file.
- In the Level field, enter DEV1 as the life cycle level for the project that will be used to load the file into Code Pipeline at that level. The level value is required to perform any Code Pipeline action.
Alternatively, in the Assignment description field, enter the assignment name to be used for the generate/build process; click Insert Variable, if desired, to choose variables to build the assignment name.
- Click Apply and Close.
In the Project Explorer view’s COB folder, right-click TPROG15.cob and select Code Pipeline>Build. The Console view shows the progress of the build.
- In the Console view, note the assignment where TPROG15 was loaded. In the example above, TPROG15 was loaded into assignment PLAY004840 at the DEV1 level.
- Delete the task from container PLAY004840 and close the container.
Task 10: Submitting the change to GitHub
To commit and push the changes to GitHub and trigger the GitHub Workflow, perform the following:
- To Commit and Push TPROG15, in the Unstaged Changes box, select TPROG15 and click
to add it to the Staged Changes box.
- In the Commit Message box, enter a commit message, such as TPROG15 commit.
- The Push Results dialog box appears.
- Click Close.
Task 11: Determining if synchronization process completed successfully
Once the TPROG15 is pushed to GitHub, the workflow on GitHub is immediately triggered (for demo purpose, ispw-sync-local-generate-deploy workflow is disabled, workflow ispw-sync-build-deploy is enabled).
- Visit GitHub repository GitPlay | Actions.
Once the job completes, click TPROG15 commit to view workflow run detail.
The following is an example of what the sync step will appear after a successful Git to Code Pipeline synchronization:Finished synchronizing changes from Git to ISPW assignment PLAY005107 at level DEV1
COB/TPROG15.cob ----- Success
1 total changes detected during synchronization: Success 1, Failure 0, Skipped 0The following is an example of what the build step will appear after a successful build:
Build parameters are being retrieved from the build_automatically input.
Starting the build process for task 7E5655E16646
ISPW: Set S000248884 - The generate request completed successfully for TPROG15 in PLAY005107. Job ID and name: J0156513 ISPWTPZG
ISPW: Set S000248884 - The build process completed successfully
The build request completed successfully.The following is an example of what the deploy step will appear after a successful build:
Deploy parameters are being retrieved from the deploy_automatically input.
Starting to submit the deploy request for task 7E5655E16646
ISPW: received set ID: S000248885
ISPW: received URL: http://10.100.12.250:48226/ispw/cw09-47623/sets/S000248885
The deploy request has been submitted.
Task 12: Verifying the updates occurred to the Mainframe
In Workbench for Eclipse’s
Code Pipeline
Containers view, find the assignment where TPROG15 was loaded and double-click the assignment. The
Code Pipeline
Tasks view appears.
Double-click TPROG15. The source is opened in the editor.
- Verify that line 8 shows TEST appended.