Skip to content

github setup package pipeline

devonfw-core edited this page Dec 27, 2022 · 3 revisions

Setting up a Package workflow on GitHub

In this section we will create a package workflow to build and push a container image of the project application into the specified container registry. This workflow will be configured in order to be triggered every time CI workflow is executed successfully on a commit for release/* and develop branches, requiring manual launch for other branches but still enforcing that CI workflow has passed. It consumes the artifact produced by the build workflow.

The creation of the GitHub action will follow the project workflow, so a new branch named feature/package-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 package 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).

Creating the workflow using provided script

Usage

pipeline_generator.sh \
  -c <config file path> \
  -n <{pipeline_type} name> \
  -l <language or framework> \
  --dockerfile <dockerfile path> \
  -d <project local path> \
  --ci-pipeline-name <ci {pipeline_type} name> \
  -i <image name> \
  [-u <registry user>] \
  [-p <registry password>] \
  [--aws-access-key <aws access key>] \
  [--aws-secret-access-key <aws secret access key>] \
  [--aws-region <aws region>] \
  [-b <branch>] \
  [-w]
Note
The config file for the package workflow is located at /scripts/pipelines/github/templates/package/package-pipeline.cfg.

Flags

-c, --config-file              [Required] Configuration file containing {pipeline_type} definition.
-n, --pipeline-name            [Required] Name that will be set to the {pipeline_type}.
-l, --language                 [Required, if dockerfile not set] Language or framework of the project.
    --dockerfile               [Required, if language not set] Path from the root of the project to its Dockerfile. Takes precedence over the language/framework default one.
-d, --local-directory          [Required] Local directory of your project.
    --ci-pipeline-name         [Required] CI {pipeline_type} name.
-i, --image-name               [Required] Name (excluding tag) for the generated container image.
-u, --registry-user            [Required, unless AWS or GCP] Container registry login user.
-p, --registry-password        [Required, unless AWS or GCP] Container registry login password.
    --aws-access-key           [Required, if AWS] AWS account access key ID. Takes precedence over registry credentials."
    --aws-secret-access-key    [Required, if AWS] AWS account secret access key."
    --aws-region               [Required, if AWS] AWS region for ECR."
-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

Quarkus project

Generic container registry
./pipeline_generator.sh -c ./templates/package/package-pipeline.cfg -n quarkus-project-package -l quarkus -d C:/Users/$USERNAME/Desktop/quarkus-project -i username/quarkus-project -u username -p password {extra_args_quarkus} -b develop -w
AWS ECR
./pipeline_generator.sh -c ./templates/package/package-pipeline.cfg -n quarkus-project-package -l quarkus -d C:/Users/$USERNAME/Desktop/quarkus-project -i username/quarkus-project --aws-access-key AKIAIOSFODNN7EXAMPLE --aws-secret-access-key wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY --aws-region eu-west-1 {extra_args_quarkus} -b develop -w

Node.js project

Generic container registry
./pipeline_generator.sh -c ./templates/package/package-pipeline.cfg -n node-project-package -l node -d C:/Users/$USERNAME/Desktop/node-project -i username/node-project -u username -p password {extra_args_node} -b develop -w
AWS ECR
./pipeline_generator.sh -c ./templates/package/package-pipeline.cfg -n node-project-package -l node -d C:/Users/$USERNAME/Desktop/node-project -i username/node-project --aws-access-key AKIAIOSFODNN7EXAMPLE --aws-secret-access-key wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY --aws-region eu-west-1 {extra_args_node} -b develop -w
==== Angular project
Generic container registry
./pipeline_generator.sh -c ./templates/package/package-pipeline.cfg -n angular-project-package -l angular -d C:/Users/$USERNAME/Desktop/angular-project --build-pipeline-name angular-project-build --quality-pipeline-name angular-project-quality -i username/angular-project -u username -p password -b develop -w
AWS ECR
./pipeline_generator.sh -c ./templates/package/package-pipeline.cfg -n angular-project-package -l angular -d C:/Users/$USERNAME/Desktop/angular-project --build-pipeline-name angular-project-build --quality-pipeline-name angular-project-quality -i username/angular-project --aws-access-key AKIAIOSFODNN7EXAMPLE --aws-secret-access-key wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY --aws-region eu-west-1 -b develop -w

Guides per provider

Clone this wiki locally