github setup ci pipeline - devonfw/hangar GitHub Wiki

Setting up a CI workflow on GitHub

In this section we will create a CI workflow for the project. This workflow will be configured to be triggered every time there is a commit to the GitHub repository, regardless of which branch it is made on. This CI workflow will execute the build workflow, and depending on the flags given, also the test and quality workflows, as its jobs.

The creation of the GitHub action will follow the project workflow, so a new branch named feature/ci-pipeline will be created and the YAML file for the workflow will be pushed to it.

Then, a Pull Request (PR) will be created in order to merge the new branch into the appropriate branch (provided in -b flag). The PR will be automatically merged if the repository policies are met. If the merge is not possible, either the PR URL will be shown as output, or it will be opened in your web browser if using -w flag.

The script located at /scripts/pipelines/github/pipeline_generator.sh will automatically create this new branch, create a CI workflow based on a YAML template, create the Pull Request and, if it is possible, merge this new branch into the specified branch.

Prerequisites

  • This script will commit and push the corresponding YAML template into your repository, so please be sure your local repository is up-to-date (i.e you have pulled latest changes with git pull).

  • An existing build workflow.

  • [Optional] An existing test workflow.

  • [Optional] An existing quality workflow.

Creating the workflow using provided script

Usage

pipeline_generator.sh \
  -c <config file path> \
  -n <workflow name> \
  -d <project local path> \
  --build-pipeline-name <build workflow name> \
  [--test-pipeline-name <test workflow name>] \
  [--quality-pipeline-name <quality workflow name>] \
  [-b <branch>] \
  [-w]
Note
The config file for the CI workflow is located at /scripts/pipelines/github/templates/ci/ci-pipeline.cfg.

Flags

-c, --config-file            [Required] Configuration file containing workflow definition.
-n, --pipeline-name          [Required] Name that will be set to the workflow.
-d, --local-directory        [Required] Local directory of your project.
    --build-pipeline-name    [Required] Name of the job calling the build workflow.
    --test-pipeline-name                Name of the job calling the test workflow.
    --quality-pipeline-name             Name of the job calling the quality workflow.
-b, --target-branch                     Name of the branch to which the Pull Request will target. PR is not created if the flag is not provided.
-w                                      Open the Pull Request on the web browser if it cannot be automatically merged. Requires -b flag.

Examples

./pipeline_generator.sh -c ./templates/ci/ci-pipeline.cfg -n ci-pipeline -d C:/Users/$USERNAME/Desktop/quarkus-project --build-pipeline-name build --test-pipeline-name test --quality-pipeline-name quality -b develop -w
⚠️ **GitHub.com Fallback** ⚠️