Skip to content

Processors_CI_CD_Workflow #107

Processors_CI_CD_Workflow

Processors_CI_CD_Workflow #107

name: Processors_CI_CD_Workflow # Define the name of the workflow
# Define when the workflow should trigger
on:
workflow_dispatch:
inputs:
knowhow_common_branch:
description: 'Type the Branch to use from knowhow-common repo'
required: true
default: 'develop'
type: string
test:
description: 'Run tests'
required: true
default: 'true'
type: choice
options:
- "false"
- "true"
deploy:
description: 'Do you want to deploy after build?'
required: true
default: 'true'
type: choice
options:
- "false"
- "true"
env:
description: 'Environment to deploy'
required: true
default: 'dev'
type: choice
options:
- dev
- dev1
- qa
- stage
processor:
description: 'Processor to build and deploy'
required: true
default: 'all'
type: choice
options:
- all
- jira
- azureboard
- azurepipelines
- devops
- rally-processor
- scm-processor
- ai-data-processor
# Define environment variables
env:
JIRA_NAME: knowhow-processors-jira
DEVOPS_NAME: knowhow-processors-devops-processor
AZUREBOARD_NAME: knowhow-processors-azure-boards
AZUREPIPELINE_NAME: knowhow-processors-azure-pipeline-repo-processor
RALLY_NAME: knowhow-processors-rally
SCM_NAME: knowhow-processors-knowhow-scm-processor
AI_DATA_PROCESSOR_NAME: knowhow-processors-ai-data-processor
ACR_NAME: ${{ secrets.SPEEDTOOLS_ACR_NAME }} # without .azurecr.io
ACR_LOGIN_SERVER: ${{ secrets.SPEEDTOOLS_ACR_LOGIN_SERVER }} # e.g. myacr.azurecr.io
BITBUCKET_HELM_REPO: ${{ secrets.SPEEDTOOLS_BITBUCKET_HELM_REPO }} # HTTPS clone URL (without creds)
GITHUB_HEAD_NAME: $GITHUB_HEAD_REF # Store the head branch name
sonartoken: ${{ secrets.SONARQUBE_TOKEN }} # Secret for SonarQube authentication
sonarurl: ${{ secrets.SONARURL }} # SonarQube URL stored in secrets
jobs:
# ✅ Building & Testing Processors
build:
runs-on: ubuntu-latest
timeout-minutes: 40
steps:
- name: Set IMAGE_TAG and values file
id: set_env
run: |
ENV="${{ github.event.inputs.env }}"
if [[ "$ENV" == "qa" ]]; then
echo "IMAGE_TAG=qa-${GITHUB_SHA::8}" >> $GITHUB_ENV
echo "VALUES_FILE=values-qa.yaml" >> $GITHUB_ENV
elif [[ "$ENV" == "stage" ]]; then
echo "IMAGE_TAG=master-${GITHUB_SHA::8}" >> $GITHUB_ENV
echo "VALUES_FILE=values-stage.yaml" >> $GITHUB_ENV
elif [[ "$ENV" == "dev1" ]]; then
echo "IMAGE_TAG=dev1-${GITHUB_SHA::8}" >> $GITHUB_ENV
echo "VALUES_FILE=values-dev1.yaml" >> $GITHUB_ENV
else
echo "IMAGE_TAG=dev-${GITHUB_SHA::8}" >> $GITHUB_ENV
echo "VALUES_FILE=values-dev.yaml" >> $GITHUB_ENV
fi
- name: Checkout Repository
uses: actions/checkout@v2
- name: Set Up Java
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '17'
- name: Cache Maven packages
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Configure Maven to use GitHub Packages
run: |
mkdir -p ~/.m2
cat > ~/.m2/settings.xml <<EOF
<settings>
<servers>
<server>
<id>github</id>
<username>${{ github.actor }}</username>
<password>${{ secrets.MAVEN_TOKEN }}</password>
</server>
</servers>
<profiles>
<profile>
<id>github</id>
<repositories>
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/PublicisSapient/knowhow-retro-notifications-lib</url>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>github</activeProfile>
</activeProfiles>
</settings>
EOF
- name: Clone & Build knowhow-common dependency
run: |
BRANCH_TO_CLONE="${{ github.event.inputs.knowhow_common_branch }}"
git clone --branch $BRANCH_TO_CLONE https://github.com/PublicisSapient/knowhow-common.git
cd knowhow-common
mvn clean install -Ddockerfile.skip=true
- name: Get common version using Maven Help Plugin
run: |
cd knowhow-common
COMMON_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "COMMON_VERSION=$COMMON_VERSION"
echo "COMMON_VERSION=$COMMON_VERSION" >> $GITHUB_ENV
- name: Updating the common version in processor project
run: |
mvn versions:use-dep-version \
-Dincludes=com.publicissapient.kpidashboard:common \
-DdepVersion=$COMMON_VERSION \
-DforceVersion=true
- name: Build & Skip Test Processor
if: ${{ github.event.inputs.test == 'false' }}
run: |
mvn clean install -Ddockerfile.skip=true -DskipTests
- name: Build & Test Processor
if: ${{ github.event.inputs.test == 'true' }}
run: |
mvn clean install -Ddockerfile.skip=true
- name: SonarQube Analysis - Processors
if: ${{ github.event.inputs.test == 'true' }}
run: |
mvn sonar:sonar -Dsonar.projectKey=ENGINEERING.KPIDASHBOARD.PROCESSORS \
-Dsonar.projectName=ENGINEERING.KPIDASHBOARD.PROCESSORS \
-Dsonar.branch.name=${{ env.GITHUB_HEAD_NAME }} \
-Dsonar.host.url=${{ secrets.SONARQUBE_HOST }} \
-Dsonar.login=${{ secrets.SONARQUBE_TOKEN }} -f pom.xml
- name: Check SonarQube Quality Gate
if: ${{ github.event.inputs.test == 'true' }}
run: |
chmod +x SonarQG.sh
./SonarQG.sh ./target/sonar/report-task.txt
- name: Build & Push Jira Docker Image
if: ${{ github.event.inputs.processor == 'all' || github.event.inputs.processor == 'jira' }}
run: |
docker login $ACR_LOGIN_SERVER --username ${{ secrets.SPEEDTOOLS_ACR_USERNAME }} --password ${{ secrets.SPEEDTOOLS_ACR_PASSWORD }}
docker build -t $ACR_LOGIN_SERVER/$JIRA_NAME:$IMAGE_TAG jira/.
docker push $ACR_LOGIN_SERVER/$JIRA_NAME:$IMAGE_TAG
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV
- name: Build & Push DevOps Docker Image
if: ${{ github.event.inputs.processor == 'all' || github.event.inputs.processor == 'devops' }}
run: |
docker login $ACR_LOGIN_SERVER --username ${{ secrets.SPEEDTOOLS_ACR_USERNAME }} --password ${{ secrets.SPEEDTOOLS_ACR_PASSWORD }}
docker build -t $ACR_LOGIN_SERVER/$DEVOPS_NAME:$IMAGE_TAG -f devops-processor-startup/Dockerfile .
docker push $ACR_LOGIN_SERVER/$DEVOPS_NAME:$IMAGE_TAG
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV
- name: Build & Push Rally Docker Image
if: ${{ github.event.inputs.processor == 'all' || github.event.inputs.processor == 'rally-processor' }}
run: |
docker login $ACR_LOGIN_SERVER --username ${{ secrets.SPEEDTOOLS_ACR_USERNAME }} --password ${{ secrets.SPEEDTOOLS_ACR_PASSWORD }}
docker build -t $ACR_LOGIN_SERVER/$RALLY_NAME:$IMAGE_TAG rally/.
docker push $ACR_LOGIN_SERVER/$RALLY_NAME:$IMAGE_TAG
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV
- name: Build & Push AzureBoard Docker Image
if: ${{ github.event.inputs.processor == 'all' || github.event.inputs.processor == 'azureboard' }}
run: |
docker login $ACR_LOGIN_SERVER --username ${{ secrets.SPEEDTOOLS_ACR_USERNAME }} --password ${{ secrets.SPEEDTOOLS_ACR_PASSWORD }}
docker build -t $ACR_LOGIN_SERVER/$AZUREBOARD_NAME:$IMAGE_TAG azure-boards/.
docker push $ACR_LOGIN_SERVER/$AZUREBOARD_NAME:$IMAGE_TAG
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV
- name: Build & Push Azure Pipeline repo Docker Image
if: ${{ github.event.inputs.processor == 'all' || github.event.inputs.processor == 'azurepipelines' }}
run: |
docker login $ACR_LOGIN_SERVER --username ${{ secrets.SPEEDTOOLS_ACR_USERNAME }} --password ${{ secrets.SPEEDTOOLS_ACR_PASSWORD }}
docker build -t $ACR_LOGIN_SERVER/$AZUREPIPELINE_NAME:$IMAGE_TAG -f azure-pipeline-repo-processor-startup/Dockerfile .
docker push $ACR_LOGIN_SERVER/$AZUREPIPELINE_NAME:$IMAGE_TAG
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV
- name: Build & Push SCM Processor Docker Image
if: ${{ github.event.inputs.processor == 'all' || github.event.inputs.processor == 'scm-processor' }}
run: |
docker login $ACR_LOGIN_SERVER --username ${{ secrets.SPEEDTOOLS_ACR_USERNAME }} --password ${{ secrets.SPEEDTOOLS_ACR_PASSWORD }}
docker build -t $ACR_LOGIN_SERVER/$SCM_NAME:$IMAGE_TAG knowhow-scm-processor/.
docker push $ACR_LOGIN_SERVER/$SCM_NAME:$IMAGE_TAG
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV
- name: Build & Push AI Data Processor Docker Image
if: ${{ github.event.inputs.processor == 'all' || github.event.inputs.processor == 'ai-data-processor' }}
run: |
docker login $ACR_LOGIN_SERVER --username ${{ secrets.SPEEDTOOLS_ACR_USERNAME }} --password ${{ secrets.SPEEDTOOLS_ACR_PASSWORD }}
docker build -t $ACR_LOGIN_SERVER/$AI_DATA_PROCESSOR_NAME:$IMAGE_TAG ai-data-processor/.
docker push $ACR_LOGIN_SERVER/$AI_DATA_PROCESSOR_NAME:$IMAGE_TAG
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV
- name: Checkout Helm charts repo
if: ${{ github.event.inputs.deploy == 'true' && ( github.event.inputs.processor == 'all' || github.event.inputs.processor == 'jira' || github.event.inputs.processor == 'devops' || github.event.inputs.processor == 'azureboard' || github.event.inputs.processor == 'azurepipelines' || github.event.inputs.processor == 'scm-processor' || github.event.inputs.processor == 'rally-processor' || github.event.inputs.processor == 'ai-data-processor' ) }}
run: |
git clone ${{ secrets.SPEEDTOOLS_BITBUCKET_HELM_REPO }}
- name: Update Jira Helm values with new image tag
if: ${{ github.event.inputs.deploy == 'true' && ( github.event.inputs.processor == 'all' || github.event.inputs.processor == 'jira' ) }}
run: |
cd build-configurations/KnowHOW-Deploy/$JIRA_NAME
# Update values.yaml image tag
yq -i ".image.tag = \"${IMAGE_TAG}\"" $VALUES_FILE
git config user.name "github-actions"
git config user.email "[email protected]"
git add $VALUES_FILE
git diff --cached --quiet || git commit -m "Update image tag values to ${IMAGE_TAG}"
git push origin HEAD
- name: Update devops Helm values with new image tag
if: ${{ github.event.inputs.deploy == 'true' && ( github.event.inputs.processor == 'all' || github.event.inputs.processor == 'devops' ) }}
run: |
cd build-configurations/KnowHOW-Deploy/$DEVOPS_NAME
# Update values.yaml image tag
yq -i ".image.tag = \"${IMAGE_TAG}\"" $VALUES_FILE
git config user.name "github-actions"
git config user.email "[email protected]"
git add $VALUES_FILE
git diff --cached --quiet || git commit -m "Update image tag values to ${IMAGE_TAG}"
git push origin HEAD
- name: Update azure board Helm values with new image tag
if: ${{ github.event.inputs.deploy == 'true' && ( github.event.inputs.processor == 'all' || github.event.inputs.processor == 'azureboard' ) }}
run: |
cd build-configurations/KnowHOW-Deploy/$AZUREBOARD_NAME
# Update values.yaml image tag
yq -i ".image.tag = \"${IMAGE_TAG}\"" $VALUES_FILE
git config user.name "github-actions"
git config user.email "[email protected]"
git add $VALUES_FILE
git diff --cached --quiet || git commit -m "Update image tag values to ${IMAGE_TAG}"
git push origin HEAD
- name: Update azure pipeline Helm values with new image tag
if: ${{ github.event.inputs.deploy == 'true' && ( github.event.inputs.processor == 'all' || github.event.inputs.processor == 'azurepipelines' ) }}
run: |
cd build-configurations/KnowHOW-Deploy/$AZUREPIPELINE_NAME
# Update values.yaml image tag
yq -i ".image.tag = \"${IMAGE_TAG}\"" $VALUES_FILE
git config user.name "github-actions"
git config user.email "[email protected]"
git add $VALUES_FILE
git diff --cached --quiet || git commit -m "Update image tag values to ${IMAGE_TAG}"
git push origin HEAD
- name: Update scm Helm values with new image tag
if: ${{ github.event.inputs.deploy == 'true' && ( github.event.inputs.processor == 'all' || github.event.inputs.processor == 'scm-processor' ) }}
run: |
cd build-configurations/KnowHOW-Deploy/$SCM_NAME
# Update values.yaml image tag
yq -i ".image.tag = \"${IMAGE_TAG}\"" $VALUES_FILE
git config user.name "github-actions"
git config user.email "[email protected]"
git add $VALUES_FILE
git diff --cached --quiet || git commit -m "Update image tag values to ${IMAGE_TAG}"
git push origin HEAD
- name: Update AI Data Processor Helm values with new image tag
if: ${{ github.event.inputs.deploy == 'true' && ( github.event.inputs.processor == 'all' || github.event.inputs.processor == 'ai-data-processor' ) }}
run: |
cd build-configurations/KnowHOW-Deploy/$AI_DATA_PROCESSOR_NAME
# Update values.yaml image tag
yq -i ".image.tag = \"${IMAGE_TAG}\"" $VALUES_FILE
git config user.name "github-actions"
git config user.email "[email protected]"
git add $VALUES_FILE
git diff --cached --quiet || git commit -m "Update image tag values to ${IMAGE_TAG}"
git push origin HEAD
- name: Update Rally Processor Helm values with new image tag
if: ${{ github.event.inputs.deploy == 'true' && ( github.event.inputs.processor == 'all' || github.event.inputs.processor == 'rally-processor' ) }}
run: |
cd build-configurations/KnowHOW-Deploy/$RALLY_NAME
# Update values.yaml image tag
yq -i ".image.tag = \"${IMAGE_TAG}\"" $VALUES_FILE
git config user.name "github-actions"
git config user.email "[email protected]"
git add $VALUES_FILE
git diff --cached --quiet || git commit -m "Update image tag values to ${IMAGE_TAG}"
git push origin HEAD
deploy-jira:
runs-on: github-actions-self-hosted-runner
timeout-minutes: 30
needs: [build]
if: ${{ github.event.inputs.deploy == 'true' && (github.event.inputs.processor == 'all' || github.event.inputs.processor == 'jira') }}
steps:
- name: Install ArgoCD CLI
run: |
export ARGO_PATH="$HOME/bin"
mkdir -p $ARGO_PATH
curl -sSL -o "$ARGO_PATH/argocd" https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64
chmod +x "$ARGO_PATH/argocd"
echo "$ARGO_PATH" >> $GITHUB_PATH
- name: ArgoCD CLI Login
run: |
argocd login argocd-server \
--username ${{ secrets.SPEEDTOOLS_ARGOCD_USERNAME}} \
--password ${{ secrets.SPEEDTOOLS_ARGOCD_PASSWORD }} \
--plaintext
- name: Deploy Jira Processor
run: |
argocd app sync $JIRA_NAME-${{ github.event.inputs.env }}
argocd app wait $JIRA_NAME-${{ github.event.inputs.env }} --health --timeout 300
deploy-rally:
runs-on: github-actions-self-hosted-runner
timeout-minutes: 30
needs: [build]
if: ${{ github.event.inputs.deploy == 'true' && (github.event.inputs.processor == 'all' || github.event.inputs.processor == 'rally-processor') }}
steps:
- name: Install ArgoCD CLI
run: |
export ARGO_PATH="$HOME/bin"
mkdir -p $ARGO_PATH
curl -sSL -o "$ARGO_PATH/argocd" https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64
chmod +x "$ARGO_PATH/argocd"
echo "$ARGO_PATH" >> $GITHUB_PATH
- name: ArgoCD CLI Login
run: |
argocd login argocd-server \
--username ${{ secrets.SPEEDTOOLS_ARGOCD_USERNAME}} \
--password ${{ secrets.SPEEDTOOLS_ARGOCD_PASSWORD }} \
--plaintext
- name: Deploy Rally Processor
run: |
argocd app sync $RALLY_NAME-${{ github.event.inputs.env }}
argocd app wait $RALLY_NAME-${{ github.event.inputs.env }} --health --timeout 300
deploy-az-board:
runs-on: github-actions-self-hosted-runner
timeout-minutes: 30
needs: [build]
if: ${{ github.event.inputs.deploy == 'true' && (github.event.inputs.processor == 'all' || github.event.inputs.processor == 'azureboard') }}
steps:
- name: Install ArgoCD CLI
run: |
export ARGO_PATH="$HOME/bin"
mkdir -p $ARGO_PATH
curl -sSL -o "$ARGO_PATH/argocd" https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64
chmod +x "$ARGO_PATH/argocd"
echo "$ARGO_PATH" >> $GITHUB_PATH
- name: ArgoCD CLI Login
run: |
argocd login argocd-server \
--username ${{ secrets.SPEEDTOOLS_ARGOCD_USERNAME}} \
--password ${{ secrets.SPEEDTOOLS_ARGOCD_PASSWORD }} \
--plaintext
- name: Deploy Azure Board Processor
run: |
argocd app sync $AZUREBOARD_NAME-${{ github.event.inputs.env }}
argocd app wait $AZUREBOARD_NAME-${{ github.event.inputs.env }} --health --timeout 300
deploy-az-pipeline:
runs-on: github-actions-self-hosted-runner
timeout-minutes: 30
needs: [build]
if: ${{ github.event.inputs.deploy == 'true' && (github.event.inputs.processor == 'all' || github.event.inputs.processor == 'azurepipelines') }}
steps:
- name: Install ArgoCD CLI
run: |
export ARGO_PATH="$HOME/bin"
mkdir -p $ARGO_PATH
curl -sSL -o "$ARGO_PATH/argocd" https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64
chmod +x "$ARGO_PATH/argocd"
echo "$ARGO_PATH" >> $GITHUB_PATH
- name: ArgoCD CLI Login
run: |
argocd login argocd-server \
--username ${{ secrets.SPEEDTOOLS_ARGOCD_USERNAME}} \
--password ${{ secrets.SPEEDTOOLS_ARGOCD_PASSWORD }} \
--plaintext
- name: Deploy Azure Pipeline Processor
run: |
argocd app sync $AZUREPIPELINE_NAME-${{ github.event.inputs.env }}
argocd app wait $AZUREPIPELINE_NAME-${{ github.event.inputs.env }} --health --timeout 300
deploy-scm-processor:
runs-on: github-actions-self-hosted-runner
timeout-minutes: 30
needs: [build]
if: ${{ github.event.inputs.deploy == 'true' && (github.event.inputs.processor == 'all' || github.event.inputs.processor == 'scm-processor') }}
steps:
- name: Install ArgoCD CLI
run: |
export ARGO_PATH="$HOME/bin"
mkdir -p $ARGO_PATH
curl -sSL -o "$ARGO_PATH/argocd" https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64
chmod +x "$ARGO_PATH/argocd"
echo "$ARGO_PATH" >> $GITHUB_PATH
- name: ArgoCD CLI Login
run: |
argocd login argocd-server \
--username ${{ secrets.SPEEDTOOLS_ARGOCD_USERNAME}} \
--password ${{ secrets.SPEEDTOOLS_ARGOCD_PASSWORD }} \
--plaintext
- name: Deploy SCM Processor
run: |
argocd app sync $SCM_NAME-${{ github.event.inputs.env }}
argocd app wait $SCM_NAME-${{ github.event.inputs.env }} --health --timeout 300
deploy-ai-processor:
runs-on: github-actions-self-hosted-runner
timeout-minutes: 30
needs: [build]
if: ${{ github.event.inputs.deploy == 'true' && (github.event.inputs.processor == 'all' || github.event.inputs.processor == 'ai-data-processor') }}
steps:
- name: Install ArgoCD CLI
run: |
export ARGO_PATH="$HOME/bin"
mkdir -p $ARGO_PATH
curl -sSL -o "$ARGO_PATH/argocd" https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64
chmod +x "$ARGO_PATH/argocd"
echo "$ARGO_PATH" >> $GITHUB_PATH
- name: ArgoCD CLI Login
run: |
argocd login argocd-server \
--username ${{ secrets.SPEEDTOOLS_ARGOCD_USERNAME}} \
--password ${{ secrets.SPEEDTOOLS_ARGOCD_PASSWORD }} \
--plaintext
- name: Deploy AI Data Processor
run: |
argocd app sync $AI_DATA_PROCESSOR_NAME-${{ github.event.inputs.env }}
argocd app wait $AI_DATA_PROCESSOR_NAME-${{ github.event.inputs.env }} --health --timeout 300
deploy-devops:
runs-on: github-actions-self-hosted-runner
timeout-minutes: 30
needs: [build]
if: ${{ github.event.inputs.deploy == 'true' && (github.event.inputs.processor == 'all' || github.event.inputs.processor == 'devops') }}
steps:
- name: Install ArgoCD CLI
run: |
export ARGO_PATH="$HOME/bin"
mkdir -p $ARGO_PATH
curl -sSL -o "$ARGO_PATH/argocd" https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64
chmod +x "$ARGO_PATH/argocd"
echo "$ARGO_PATH" >> $GITHUB_PATH
- name: ArgoCD CLI Login
run: |
argocd login argocd-server \
--username ${{ secrets.SPEEDTOOLS_ARGOCD_USERNAME}} \
--password ${{ secrets.SPEEDTOOLS_ARGOCD_PASSWORD }} \
--plaintext
- name: Deploy DevOps Processor
run: |
argocd app sync $DEVOPS_NAME-${{ github.event.inputs.env }}
argocd app wait $DEVOPS_NAME-${{ github.event.inputs.env }} --health --timeout 1200