Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/GitHub deploy workflow #179

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
ce7673c
updated with github deploy workflow
prathibhapadma Jul 18, 2022
59cb072
updated
prathibhapadma Jul 18, 2022
58f2221
Automatic generation of documentation
prathibhapadma Jul 18, 2022
ee16702
update with tag
prathibhapadma Jul 19, 2022
919ecc5
Update deploy.sh
prathibhapadma Jul 19, 2022
cf4ed3a
Update deploy-pipeline.yml.template
prathibhapadma Jul 19, 2022
1155ab3
Update deploy-pipeline.yml.template
prathibhapadma Jul 20, 2022
0ec4aa6
Update pipeline_generator.sh
prathibhapadma Jul 20, 2022
c43b52a
Update deploy.sh
prathibhapadma Jul 20, 2022
075cfb3
tag_completed was unused
ultymatom Jul 21, 2022
2a706b5
Update deploy.sh
ultymatom Jul 21, 2022
ce4379d
commit intermediaire
ultymatom Aug 25, 2022
e5650f5
Merge branch 'devonfw:master' into feature/github_deploy_workflow
prathibhapadma Aug 25, 2022
e51397e
works well !
ultymatom Aug 31, 2022
c714dd4
Merge remote-tracking branch 'origin/feature/github_deploy_workflow' …
ultymatom Aug 31, 2022
821d9bc
Update setup-deploy-pipeline.asciidoc
prathibhapadma Sep 22, 2022
451a7c3
Automatic generation of documentation
prathibhapadma Sep 22, 2022
cf8fcfd
Update setup-deploy-pipeline.asciidoc
prathibhapadma Sep 22, 2022
1998d19
Automatic generation of documentation
prathibhapadma Sep 22, 2022
334d2fc
Merge branch 'devonfw:master' into feature/github_deploy_workflow
prathibhapadma Sep 23, 2022
ae88d59
Merge branch 'master' into feature/github_deploy_workflow
prathibhapadma Oct 18, 2022
584b15c
fixed with line ending checks
prathibhapadma Oct 18, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions documentation/azure-devops/setup-deploy-pipeline.asciidoc
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
= Setting up a Deploy Pipeline on Azure DevOps
:provider: Azure Devops
:pipeline_type: Pipeline
:trigger_sentence:
:pipeline_type2: pipeline
:path_provider: azure-devops
= Setting up a Deploy Pipeline on {provider}

In this section we will create a deploy pipeline on Azure DevOps to deploy the project application on an already provisioned Kubernetes cluster. This pipeline will be configured in order to be triggered every time package pipeline is executed successfully on a commit for `release/*` and `develop` branches, requiring manual launch for other branches but still enforcing that package pipeline has passed. By default, it depends on the environment provisioning pipeline being successfully run on beforehand and, depending on the Kubernetes provider, it consumes the artifact produced by that. It also consumes variable groups created by package and environment provisioning pipelines.
In this section we will create a deploy {pipeline_type} on {provider} to deploy the project application on an already provisioned Kubernetes cluster. This pipeline will be configured in order to be triggered every time package {pipeline_type} is executed successfully on a commit for `release/*` and `develop` branches, requiring manual launch for other branches but still enforcing that package {pipeline_type} has passed. By default, it depends on the environment provisioning {pipeline_type} being successfully run on beforehand and, depending on the Kubernetes provider, it consumes the artifact produced by that. It also consumes variable groups created by package and environment provisioning {pipeline_type}.

The creation of the pipeline will follow the project workflow, so a new branch named `feature/deploy-pipeline` will be created and the YAML file for the pipeline 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/azure-devops/pipeline_generator.sh` will automatically create the new branch, create a deploy pipeline based on a YAML template appropriate for the project manifests files, create the Pull Request, and if it is possible, merge this new branch into the specified branch.
The script located at `/scripts/pipelines/{path_provider}/pipeline_generator.sh` will automatically create the new branch, create a deploy pipeline based on a YAML template appropriate for the project manifests files, 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 the latest changes with `git pull`).

* The YAML containing Deployment object should be named `application-deployment.yaml` for allowing automated `imagePullSecret` injection.

== Creating the pipeline using provided script
== Creating the {pipeline_type} using provided script

=== Usage
```
Expand All @@ -26,12 +31,12 @@ pipeline_generator.sh \
--env-provision-pipeline-name <pipeline name>] \
--k8s-provider <provider name> \
--k8s-namespace <namespace> \
--k8s-deploy-files-path <manifests path> \
--k8s-deploy-files-path <manifests path> \
[--k8s-image-pull-secret-name <secret name>] \
[-b <branch>] \
[-w]
```
NOTE: The config file for the deploy pipeline is located at `/scripts/pipelines/azure-devops/templates/deploy/deploy-pipeline.cfg`.
NOTE: The config file for the deploy pipeline is located at `/scripts/pipelines/{path_provider}/templates/deploy/deploy-pipeline.cfg`.

=== Flags
```
Expand All @@ -43,7 +48,7 @@ NOTE: The config file for the deploy pipeline is located at `/scripts/pipelines
--k8s-provider [Required] Kubernetes cluster provider name. Accepted values: EKS, AKS.
--k8s-namespace [Required] Kubernetes namespace where the application will be deployed.
--k8s-deploy-files-path [Required] Path from the root of the project to the YAML manifests directory.
--k8s-image-pull-secret-name Name for the generated secret containing registry credentials. Required when using a private registry to host images.
--k8s-image-pull-secret-name Name for the generated secret containing registry credentials. Required when using a private registry to host images.
-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.
```
Expand All @@ -57,7 +62,7 @@ NOTE: The config file for the deploy pipeline is located at `/scripts/pipelines

=== Appendix: accessing the application

Once the pipeline is executed and your application is deployed, you can list the hostname to access it with:
Once the {pipeline_type} is executed and your application is deployed, you can list the hostname to access it with:

```
kubectl get ingress -n <namespace>
Expand Down
69 changes: 69 additions & 0 deletions documentation/github/setup-deploy-pipeline.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
:provider: Github
:pipeline_type: workflow
:trigger_sentence:
:pipeline_type2: Github action
:path_provider: github
= Setting up a Deploy Pipeline on {provider}

In this section we will create a deploy {pipeline_type} on {provider} to deploy the project application on an already provisioned Kubernetes cluster. This pipeline will be configured in order to be triggered every time package {pipeline_type} is executed successfully on a commit for `release/*` and `develop` branches, requiring manual launch for other branches but still enforcing that package {pipeline_type} has passed. By default, it depends on the environment provisioning {pipeline_type} being successfully run on beforehand and, depending on the Kubernetes provider, it consumes the artifact produced by that. It also consumes variable groups created by package and environment provisioning {pipeline_type}.

The creation of the pipeline will follow the project workflow, so a new branch named `feature/deploy-pipeline` will be created and the YAML file for the pipeline 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/{path_provider}/pipeline_generator.sh` will automatically create the new branch, create a deploy pipeline based on a YAML template appropriate for the project manifests files, 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 the latest changes with `git pull`).

* The YAML containing Deployment object should be named `application-deployment.yaml` for allowing automated `imagePullSecret` injection.

== Creating the {pipeline_type} using provided script

=== Usage
```
pipeline_generator.sh \
-c <config file path> \
-n <pipeline name> \
-d <project local path> \
--package-pipeline-name <pipeline name> \
--env-provision-pipeline-name <pipeline name>] \
--k8s-provider <provider name> \
--k8s-namespace <namespace> \
--k8s-deploy-files-path <manifests path> \
[--k8s-image-pull-secret-name <secret name>] \
[-b <branch>] \
[-w]
```
NOTE: The config file for the deploy pipeline is located at `/scripts/pipelines/{path_provider}/templates/deploy/deploy-pipeline.cfg`.

=== Flags
```
-c --config-file [Required] Configuration file containing pipeline definition.
-n --pipeline-name [Required] Name that will be set to the pipeline.
-d --local-directory [Required] Local directory of your project.
--package-pipeline-name [Required] Package pipeline name.
--env-provision-pipeline-name [Required] Environment provisioning pipeline name.
--k8s-provider [Required] Kubernetes cluster provider name. Accepted values: EKS, AKS.
--k8s-namespace [Required] Kubernetes namespace where the application will be deployed.
--k8s-deploy-files-path [Required] Path from the root of the project to the YAML manifests directory.
--k8s-image-pull-secret-name Name for the generated secret containing registry credentials. Required when using a private registry to host images.
-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/deploy/deploy-pipeline.cfg -n quarkus-project-deploy -d C:/Users/$USERNAME/Desktop/quarkus-project --package-pipeline-name quarkus-project-package --env-provision-pipeline-name eks-provisioning --k8s-provider EKS --k8s-namespace hangar --k8s-deploy-files-path k8s -b develop -w
```


=== Appendix: accessing the application

Once the {pipeline_type} is executed and your application is deployed, you can list the hostname to access it with:

```
kubectl get ingress -n <namespace>
```
6 changes: 6 additions & 0 deletions documentation/src/azure-devops/setup-deploy-pipeline.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
:provider: Azure Devops
:pipeline_type: Pipeline
:trigger_sentence:
:pipeline_type2: pipeline
:path_provider: azure-devops
include::../common_templates/setup-deploy-pipeline.asciidoc[]
64 changes: 64 additions & 0 deletions documentation/src/common_templates/setup-deploy-pipeline.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
= Setting up a Deploy Pipeline on {provider}

In this section we will create a deploy {pipeline_type} on {provider} to deploy the project application on an already provisioned Kubernetes cluster. This pipeline will be configured in order to be triggered every time package {pipeline_type} is executed successfully on a commit for `release/*` and `develop` branches, requiring manual launch for other branches but still enforcing that package {pipeline_type} has passed. By default, it depends on the environment provisioning {pipeline_type} being successfully run on beforehand and, depending on the Kubernetes provider, it consumes the artifact produced by that. It also consumes variable groups created by package and environment provisioning {pipeline_type}.

The creation of the pipeline will follow the project workflow, so a new branch named `feature/deploy-pipeline` will be created and the YAML file for the pipeline 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/{path_provider}/pipeline_generator.sh` will automatically create the new branch, create a deploy pipeline based on a YAML template appropriate for the project manifests files, 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 the latest changes with `git pull`).

* The YAML containing Deployment object should be named `application-deployment.yaml` for allowing automated `imagePullSecret` injection.

== Creating the {pipeline_type} using provided script

=== Usage
```
pipeline_generator.sh \
-c <config file path> \
-n <pipeline name> \
-d <project local path> \
--package-pipeline-name <pipeline name> \
--env-provision-pipeline-name <pipeline name>] \
--k8s-provider <provider name> \
--k8s-namespace <namespace> \
--k8s-deploy-files-path <manifests path> \
[--k8s-image-pull-secret-name <secret name>] \
[-b <branch>] \
[-w]
```
NOTE: The config file for the deploy pipeline is located at `/scripts/pipelines/{path_provider}/templates/deploy/deploy-pipeline.cfg`.

=== Flags
```
-c --config-file [Required] Configuration file containing pipeline definition.
-n --pipeline-name [Required] Name that will be set to the pipeline.
-d --local-directory [Required] Local directory of your project.
--package-pipeline-name [Required] Package pipeline name.
--env-provision-pipeline-name [Required] Environment provisioning pipeline name.
--k8s-provider [Required] Kubernetes cluster provider name. Accepted values: EKS, AKS.
--k8s-namespace [Required] Kubernetes namespace where the application will be deployed.
--k8s-deploy-files-path [Required] Path from the root of the project to the YAML manifests directory.
--k8s-image-pull-secret-name Name for the generated secret containing registry credentials. Required when using a private registry to host images.
-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/deploy/deploy-pipeline.cfg -n quarkus-project-deploy -d C:/Users/$USERNAME/Desktop/quarkus-project --package-pipeline-name quarkus-project-package --env-provision-pipeline-name eks-provisioning --k8s-provider EKS --k8s-namespace hangar --k8s-deploy-files-path k8s -b develop -w
```


=== Appendix: accessing the application

Once the {pipeline_type} is executed and your application is deployed, you can list the hostname to access it with:

```
kubectl get ingress -n <namespace>
```
6 changes: 6 additions & 0 deletions documentation/src/github/setup-deploy-pipeline.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
:provider: Github
:pipeline_type: workflow
:trigger_sentence:
:pipeline_type2: Github action
:path_provider: github
include::../common_templates/setup-deploy-pipeline.asciidoc[]
8 changes: 7 additions & 1 deletion scripts/pipelines/github/pipeline_generator.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
set -e
FLAGS=$(getopt -a --options c:n:d:a:b:l:i:u:p:hw --long "config-file:,pipeline-name:,local-directory:,artifact-path:,target-branch:,language:,build-pipeline-name:,sonar-url:,sonar-token:,image-name:,registry-user:,registry-password:,resource-group:,storage-account:,storage-container:,cluster-name:,s3-bucket:,s3-key-path:,quality-pipeline-name:,dockerfile:,test-pipeline-name:,aws-access-key:,aws-secret-access-key:,aws-region:,ci-pipeline-name:,help" -- "$@")
FLAGS=$(getopt -a --options c:n:d:a:b:l:i:u:p:hw --long "config-file:,pipeline-name:,local-directory:,artifact-path:,target-branch:,language:,build-pipeline-name:,sonar-url:,sonar-token:,image-name:,registry-user:,registry-password:,resource-group:,storage-account:,storage-container:,cluster-name:,s3-bucket:,s3-key-path:,quality-pipeline-name:,dockerfile:,test-pipeline-name:,aws-access-key:,aws-secret-access-key:,aws-region:,rancher:,ci-pipeline-name:,package-pipeline-name:,env-provision-pipeline-name:,k8s-provider:,k8s-namespace:,k8s-deploy-files-path:,k8s-image-pull-secret-name:,help" -- "$@")

eval set -- "$FLAGS"
while true; do
Expand Down Expand Up @@ -30,6 +30,12 @@ while true; do
--aws-access-key) awsAccessKey="$2"; shift 2;;
--aws-secret-access-key) awsSecretAccessKey="$2"; shift 2;;
--aws-region) awsRegion="$2"; shift 2;;
--package-pipeline-name) export packagePipelineName=$2; shift 2;;
--env-provision-pipeline-name) envProvisionPipelineName="$2"; shift 2;;
ultymatom marked this conversation as resolved.
Show resolved Hide resolved
prathibhapadma marked this conversation as resolved.
Show resolved Hide resolved
--k8s-provider) k8sProvider=$2; shift 2;;
ultymatom marked this conversation as resolved.
Show resolved Hide resolved
--k8s-namespace) k8sNamespace="$2"; shift 2;;
ultymatom marked this conversation as resolved.
Show resolved Hide resolved
--k8s-deploy-files-path) k8sDeployFiles=$2; shift 2;;
ultymatom marked this conversation as resolved.
Show resolved Hide resolved
--k8s-image-pull-secret-name) k8sImagePullSecret=$2; shift 2;;
ultymatom marked this conversation as resolved.
Show resolved Hide resolved
-h | --help) help="true"; shift 1;;
-w) webBrowser="true"; shift 1;;
--) shift; break;;
Expand Down
30 changes: 30 additions & 0 deletions scripts/pipelines/github/templates/deploy/deploy-pipeline.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# List of the flages we used in different stages for deploy pipeline.
# Comma separated list of flags. Make sure to end with a comma, Eg: $name,$xyz,
mandatoryFlags="$pipelineName,$localDirectory,$packagePipelineName,$envProvisionPipelineName,$k8sProvider,$k8sNamespace,$k8sDeployFiles,"
# Path to the templates.
templatesPath="scripts/pipelines/github/templates/deploy"
# YAML file name.
yamlFile="deploy-pipeline.yml"
# Source branch.
sourceBranch="feature/deploy-pipeline"

# Function that copies the extra yaml files into the directory.
function copyScript {
# Copy the deploy script.
cp "${hangarPath}/${templatesPath}/deploy.sh" "${localDirectory}/${scriptFilePath}"

# Copy the script for generating imagePullSecrets for private registries.
cp "${hangarPath}/${templatesPath}/secrets.sh" "${localDirectory}/${scriptFilePath}"
}

function addPipelineVariables {
# We cannot use a variable in the definition of resource in the pipeline so we have to use a placeholder to replace it with the value we need
export packagePipelineName
export envProvisionPipelineName
export k8sProvider
export k8sNamespace
export k8sDeployFiles
export k8sImagePullSecret
specificEnvSubstList='${packagePipelineName} ${envProvisionPipelineName} ${k8sProvider} ${k8sNamespace} ${k8sDeployFiles} ${k8sImagePullSecret}'
}

Loading