Skip to content

Commit 3886a1f

Browse files
authored
Merge pull request #86 from PublicisSapient/develop
Develop
2 parents 0186000 + 2e69c7a commit 3886a1f

File tree

5 files changed

+368
-15
lines changed

5 files changed

+368
-15
lines changed
Lines changed: 353 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,353 @@
1+
name: Processors_CI_CD_Workflow # Define the name of the workflow
2+
3+
# Define when the workflow should trigger
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
knowhow_common_branch:
8+
description: 'Type the Branch to use from knowhow-common repo'
9+
required: true
10+
default: 'develop'
11+
type: string
12+
13+
test:
14+
description: 'Run tests'
15+
required: true
16+
default: 'true'
17+
type: choice
18+
options:
19+
- "false"
20+
- "true"
21+
env:
22+
description: 'Environment to deploy'
23+
required: true
24+
default: 'dev'
25+
type: choice
26+
options:
27+
- dev
28+
- dev1
29+
- qa
30+
- stage
31+
32+
processor:
33+
description: 'Processor to build and deploy'
34+
required: true
35+
default: 'all'
36+
type: choice
37+
options:
38+
- all
39+
- jira
40+
- azureboard
41+
- azurepipelines
42+
- devops
43+
- rally-processor
44+
- scm-processor
45+
46+
# Define environment variables
47+
env:
48+
JIRA_IMAGE_NAME: knowhow-jira-processor
49+
DEVOPS_IMAGE_NAME: knowhow-devops-processor
50+
AZUREBOARD_IMAGE_NAME: knowhow-azure-board-processor
51+
AZUREPIPELINE_IMAGE_NAME: knowhow-azure-pipeline-repo
52+
SCM_IMAGE_NAME: knowhow-scm-processor
53+
ACR_NAME: ${{ secrets.SPEEDTOOLS_ACR_NAME }} # without .azurecr.io
54+
ACR_LOGIN_SERVER: ${{ secrets.SPEEDTOOLS_ACR_LOGIN_SERVER }} # e.g. myacr.azurecr.io
55+
BITBUCKET_HELM_REPO: ${{ secrets.SPEEDTOOLS_BITBUCKET_HELM_REPO }} # HTTPS clone URL (without creds)
56+
GITHUB_HEAD_NAME: $GITHUB_HEAD_REF # Store the head branch name
57+
sonartoken: ${{ secrets.SONARQUBE_TOKEN }} # Secret for SonarQube authentication
58+
sonarurl: ${{ secrets.SONARURL }} # SonarQube URL stored in secrets
59+
60+
jobs:
61+
62+
# ✅ Building & Testing Processors
63+
build:
64+
runs-on: ubuntu-latest
65+
timeout-minutes: 40
66+
steps:
67+
- name: Set IMAGE_TAG and values file
68+
id: set_env
69+
run: |
70+
ENV="${{ github.event.inputs.env }}"
71+
if [[ "$ENV" == "qa" ]]; then
72+
echo "IMAGE_TAG=qa-${GITHUB_SHA::8}" >> $GITHUB_ENV
73+
echo "VALUES_FILE=values-qa.yaml" >> $GITHUB_ENV
74+
elif [[ "$ENV" == "stage" ]]; then
75+
echo "IMAGE_TAG=master-${GITHUB_SHA::8}" >> $GITHUB_ENV
76+
echo "VALUES_FILE=values-stage.yaml" >> $GITHUB_ENV
77+
elif [[ "$ENV" == "dev1" ]]; then
78+
echo "IMAGE_TAG=dev1-${GITHUB_SHA::8}" >> $GITHUB_ENV
79+
echo "VALUES_FILE=values-dev1.yaml" >> $GITHUB_ENV
80+
else
81+
echo "IMAGE_TAG=dev-${GITHUB_SHA::8}" >> $GITHUB_ENV
82+
echo "VALUES_FILE=values-dev.yaml" >> $GITHUB_ENV
83+
fi
84+
- name: Checkout Repository
85+
uses: actions/checkout@v2
86+
87+
- name: Set Up Java
88+
uses: actions/setup-java@v2
89+
with:
90+
distribution: 'adopt'
91+
java-version: '17'
92+
93+
- name: Cache Maven packages
94+
uses: actions/cache@v4
95+
with:
96+
path: ~/.m2/repository
97+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
98+
restore-keys: |
99+
${{ runner.os }}-maven-
100+
101+
- name: Configure Maven to use GitHub Packages
102+
run: |
103+
mkdir -p ~/.m2
104+
cat > ~/.m2/settings.xml <<EOF
105+
<settings>
106+
<servers>
107+
<server>
108+
<id>github</id>
109+
<username>${{ github.actor }}</username>
110+
<password>${{ secrets.MAVEN_TOKEN }}</password>
111+
</server>
112+
</servers>
113+
<profiles>
114+
<profile>
115+
<id>github</id>
116+
<repositories>
117+
<repository>
118+
<id>github</id>
119+
<url>https://maven.pkg.github.com/PublicisSapient/knowhow-retro-notifications-lib</url>
120+
</repository>
121+
</repositories>
122+
</profile>
123+
</profiles>
124+
<activeProfiles>
125+
<activeProfile>github</activeProfile>
126+
</activeProfiles>
127+
</settings>
128+
EOF
129+
130+
- name: Clone & Build knowhow-common dependency
131+
run: |
132+
BRANCH_TO_CLONE="${{ github.event.inputs.knowhow_common_branch }}"
133+
git clone --branch $BRANCH_TO_CLONE https://github.com/PublicisSapient/knowhow-common.git
134+
cd knowhow-common
135+
mvn clean install -Ddockerfile.skip=true
136+
137+
- name: Get common version using Maven Help Plugin
138+
run: |
139+
cd knowhow-common
140+
COMMON_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
141+
echo "COMMON_VERSION=$COMMON_VERSION"
142+
echo "COMMON_VERSION=$COMMON_VERSION" >> $GITHUB_ENV
143+
144+
- name: Updating the common version in processor project
145+
run: |
146+
mvn versions:use-dep-version \
147+
-Dincludes=com.publicissapient.kpidashboard:common \
148+
-DdepVersion=$COMMON_VERSION \
149+
-DforceVersion=true
150+
151+
- name: Build & Skip Test Processor
152+
if: ${{ github.event.inputs.test == 'false' }}
153+
run: |
154+
mvn clean install -Ddockerfile.skip=true -DskipTests
155+
156+
- name: Build & Test Processor
157+
if: ${{ github.event.inputs.test == 'true' }}
158+
run: |
159+
mvn clean install -Ddockerfile.skip=true
160+
161+
- name: SonarQube Analysis - Processors
162+
if: ${{ github.event.inputs.test == 'true' }}
163+
run: |
164+
mvn sonar:sonar -Dsonar.projectKey=ENGINEERING.KPIDASHBOARD.PROCESSORS \
165+
-Dsonar.projectName=ENGINEERING.KPIDASHBOARD.PROCESSORS \
166+
-Dsonar.branch.name=${{ env.GITHUB_HEAD_NAME }} \
167+
-Dsonar.host.url=${{ secrets.SONARQUBE_HOST }} \
168+
-Dsonar.login=${{ secrets.SONARQUBE_TOKEN }} -f pom.xml
169+
170+
- name: Check SonarQube Quality Gate
171+
if: ${{ github.event.inputs.test == 'true' }}
172+
run: |
173+
chmod +x SonarQG.sh
174+
./SonarQG.sh ./target/sonar/report-task.txt
175+
176+
- name: Build & Push Jira Docker Image
177+
if: ${{ github.event.inputs.processor == 'all' || github.event.inputs.processor == 'jira' }}
178+
run: |
179+
docker login $ACR_LOGIN_SERVER --username ${{ secrets.SPEEDTOOLS_ACR_USERNAME }} --password ${{ secrets.SPEEDTOOLS_ACR_PASSWORD }}
180+
docker build -t $ACR_LOGIN_SERVER/$JIRA_IMAGE_NAME:$IMAGE_TAG jira/.
181+
docker push $ACR_LOGIN_SERVER/$JIRA_IMAGE_NAME:$IMAGE_TAG
182+
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV
183+
184+
- name: Build & Push DevOps Docker Image
185+
if: ${{ github.event.inputs.processor == 'all' || github.event.inputs.processor == 'devops' }}
186+
run: |
187+
docker login $ACR_LOGIN_SERVER --username ${{ secrets.SPEEDTOOLS_ACR_USERNAME }} --password ${{ secrets.SPEEDTOOLS_ACR_PASSWORD }}
188+
docker build -t $ACR_LOGIN_SERVER/$DEVOPS_IMAGE_NAME:$IMAGE_TAG -f devops-processor-startup/Dockerfile .
189+
docker push $ACR_LOGIN_SERVER/$DEVOPS_IMAGE_NAME:$IMAGE_TAG
190+
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV
191+
192+
- name: Build & Push AzureBoard Docker Image
193+
if: ${{ github.event.inputs.processor == 'all' || github.event.inputs.processor == 'azureboard' }}
194+
run: |
195+
docker login $ACR_LOGIN_SERVER --username ${{ secrets.SPEEDTOOLS_ACR_USERNAME }} --password ${{ secrets.SPEEDTOOLS_ACR_PASSWORD }}
196+
docker build -t $ACR_LOGIN_SERVER/$AZUREBOARD_IMAGE_NAME:$IMAGE_TAG azure-boards/.
197+
docker push $ACR_LOGIN_SERVER/$AZUREBOARD_IMAGE_NAME:$IMAGE_TAG
198+
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV
199+
200+
- name: Build & Push Azure Pipeline repo Docker Image
201+
if: ${{ github.event.inputs.processor == 'all' || github.event.inputs.processor == 'azurepipelines' }}
202+
run: |
203+
docker login $ACR_LOGIN_SERVER --username ${{ secrets.SPEEDTOOLS_ACR_USERNAME }} --password ${{ secrets.SPEEDTOOLS_ACR_PASSWORD }}
204+
docker build -t $ACR_LOGIN_SERVER/$AZUREPIPELINE_IMAGE_NAME:$IMAGE_TAG -f azure-pipeline-repo-processor-startup/Dockerfile .
205+
docker push $ACR_LOGIN_SERVER/$AZUREPIPELINE_IMAGE_NAME:$IMAGE_TAG
206+
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV
207+
208+
- name: Build & Push SCM Processor Docker Image
209+
if: ${{ github.event.inputs.processor == 'all' || github.event.inputs.processor == 'scm-processor' }}
210+
run: |
211+
docker login $ACR_LOGIN_SERVER --username ${{ secrets.SPEEDTOOLS_ACR_USERNAME }} --password ${{ secrets.SPEEDTOOLS_ACR_PASSWORD }}
212+
docker build -t $ACR_LOGIN_SERVER/$SCM_IMAGE_NAME:$IMAGE_TAG .
213+
docker push $ACR_LOGIN_SERVER/$SCM_IMAGE_NAME:$IMAGE_TAG
214+
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV
215+
216+
- name: Checkout jira Helm charts from Bitbucket
217+
if: ${{ github.event.inputs.processor == 'all' || github.event.inputs.processor == 'jira' }}
218+
run: |
219+
git clone ${{ secrets.SPEEDTOOLS_BITBUCKET_HELM_REPO }}
220+
cd build-configurations/KnowHOW-Deploy/knowhow-jira-processor
221+
# Update values.yaml image tag
222+
yq -i ".image.tag = \"${IMAGE_TAG}\"" $VALUES_FILE
223+
git config user.name "github-actions"
224+
git config user.email "github-actions@github.com"
225+
git add $VALUES_FILE
226+
git diff --cached --quiet || git commit -m "Update image tag values to ${IMAGE_TAG}"
227+
git push origin HEAD
228+
229+
- name: Checkout devops Helm charts from Bitbucket
230+
if: ${{ github.event.inputs.processor == 'all' || github.event.inputs.processor == 'devops' }}
231+
run: |
232+
git clone ${{ secrets.SPEEDTOOLS_BITBUCKET_HELM_REPO }}
233+
cd build-configurations/KnowHOW-Deploy/devops-processor
234+
# Update values.yaml image tag
235+
yq -i ".image.tag = \"${IMAGE_TAG}\"" $VALUES_FILE
236+
git config user.name "github-actions"
237+
git config user.email "github-actions@github.com"
238+
git add $VALUES_FILE
239+
git diff --cached --quiet || git commit -m "Update image tag values to ${IMAGE_TAG}"
240+
git push origin HEAD
241+
242+
- name: Checkout azure board Helm charts from Bitbucket
243+
if: ${{ github.event.inputs.processor == 'all' || github.event.inputs.processor == 'azureboard' }}
244+
run: |
245+
git clone ${{ secrets.SPEEDTOOLS_BITBUCKET_HELM_REPO }}
246+
cd build-configurations/KnowHOW-Deploy/knowhow-azure-board-processor
247+
# Update values.yaml image tag
248+
yq -i ".image.tag = \"${IMAGE_TAG}\"" $VALUES_FILE
249+
git config user.name "github-actions"
250+
git config user.email "github-actions@github.com"
251+
git add $VALUES_FILE
252+
git diff --cached --quiet || git commit -m "Update image tag values to ${IMAGE_TAG}"
253+
git push origin HEAD
254+
255+
- name: Checkout azure Pipeline Helm charts from Bitbucket
256+
if: ${{ github.event.inputs.processor == 'all' || github.event.inputs.processor == 'azurepipelines' }}
257+
run: |
258+
git clone ${{ secrets.SPEEDTOOLS_BITBUCKET_HELM_REPO }}
259+
cd build-configurations/KnowHOW-Deploy/knowhow-azure-pipeline-repo
260+
# Update values.yaml image tag
261+
yq -i ".image.tag = \"${IMAGE_TAG}\"" $VALUES_FILE
262+
git config user.name "github-actions"
263+
git config user.email "github-actions@github.com"
264+
git add $VALUES_FILE
265+
git diff --cached --quiet || git commit -m "Update image tag values to ${IMAGE_TAG}"
266+
git push origin HEAD
267+
268+
- name: Checkout scm Helm charts from Bitbucket
269+
if: ${{ github.event.inputs.processor == 'all' || github.event.inputs.processor == 'scm-processor' }}
270+
run: |
271+
git clone ${{ secrets.SPEEDTOOLS_BITBUCKET_HELM_REPO }}
272+
cd build-configurations/KnowHOW-Deploy/knowhow-scm-processor
273+
# Update values.yaml image tag
274+
yq -i ".image.tag = \"${IMAGE_TAG}\"" $VALUES_FILE
275+
git config user.name "github-actions"
276+
git config user.email "github-actions@github.com"
277+
git add $VALUES_FILE
278+
git diff --cached --quiet || git commit -m "Update image tag values to ${IMAGE_TAG}"
279+
git push origin HEAD
280+
281+
argocd-setup:
282+
runs-on: github-actions-self-hosted-runner
283+
timeout-minutes: 30
284+
needs: build
285+
steps:
286+
- name: Install ArgoCD CLI
287+
run: |
288+
export ARGO_PATH="$HOME/bin"
289+
mkdir -p $ARGO_PATH
290+
curl -sSL -o "$ARGO_PATH/argocd" https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64
291+
chmod +x "$ARGO_PATH/argocd"
292+
echo "$ARGO_PATH" >> $GITHUB_PATH
293+
294+
- name: ArgoCD CLI Login
295+
run: |
296+
argocd login argocd-server \
297+
--username ${{ secrets.SPEEDTOOLS_ARGOCD_USERNAME}} \
298+
--password ${{ secrets.SPEEDTOOLS_ARGOCD_PASSWORD }} \
299+
--plaintext
300+
deploy-jira:
301+
runs-on: github-actions-self-hosted-runner
302+
timeout-minutes: 30
303+
needs: [build, argocd-setup]
304+
steps:
305+
306+
- name: Deploy Jira Processor
307+
if: ${{ github.event.inputs.processor == 'all' || github.event.inputs.processor == 'jira' }}
308+
run: |
309+
argocd app sync knh-jira-processor-${{ github.event.inputs.env }}
310+
argocd app wait knh-jira-processor-${{ github.event.inputs.env }} --health --timeout 300
311+
deploy-az-board:
312+
runs-on: github-actions-self-hosted-runner
313+
timeout-minutes: 30
314+
needs: [build, argocd-setup]
315+
steps:
316+
- name: Deploy Azure Board Processor
317+
if: ${{ github.event.inputs.processor == 'all' || github.event.inputs.processor == 'azureboard' }}
318+
run: |
319+
argocd app sync knh-azure-board-${{ github.event.inputs.env }}
320+
argocd app wait knh-azure-board-${{ github.event.inputs.env }} --health --timeout 300
321+
322+
deploy-az-pipeline:
323+
runs-on: github-actions-self-hosted-runner
324+
timeout-minutes: 30
325+
needs: [build, argocd-setup]
326+
steps:
327+
- name: Deploy Azure Pipeline Processor
328+
if: ${{ github.event.inputs.processor == 'all' || github.event.inputs.processor == 'azurepipelines' }}
329+
run: |
330+
argocd app sync knh-azure-pipeline-repo-${{ github.event.inputs.env }}
331+
argocd app wait knh-azure-pipeline-repo-${{ github.event.inputs.env }} --health --timeout 300
332+
333+
deploy-scm-processor:
334+
runs-on: github-actions-self-hosted-runner
335+
timeout-minutes: 30
336+
needs: [build, argocd-setup]
337+
steps:
338+
- name: Deploy SCM Processor
339+
if: ${{ github.event.inputs.processor == 'all' || github.event.inputs.processor == 'scm-processor' }}
340+
run: |
341+
argocd app sync knh-scm-processor-${{ github.event.inputs.env }}
342+
argocd app wait knh-scm-processor-${{ github.event.inputs.env }} --health --timeout 300
343+
344+
deploy-devops:
345+
runs-on: github-actions-self-hosted-runner
346+
timeout-minutes: 30
347+
needs: [build, argocd-setup]
348+
steps:
349+
- name: Deploy DevOps Processor
350+
if: ${{ github.event.inputs.processor == 'all' || github.event.inputs.processor == 'devops' }}
351+
run: |
352+
argocd app sync knh-devops-processor-${{ github.event.inputs.env }}
353+
argocd app wait knh-devops-processor-${{ github.event.inputs.env }} --health --timeout 600

azure-boards/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ ENV APP_DIR="/app" \
2828
VOLUME $PROPERTIES_DIR
2929

3030
# Set the JAR file variable
31-
ARG JAR_FILE
31+
ARG JAR_FILE=target/azure-processor-exec.jar
3232
ADD ${JAR_FILE} $APP_DIR/azure.jar
3333

3434
# Copy application.properties file

azure-pipeline-repo-processor-startup/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ ENV APP_DIR="/app" \
2828
VOLUME $PROPERTIES_DIR
2929

3030
# Set the JAR file variables
31-
ARG AZUREPIPELINE_JAR_FILE=azure-pipeline/target/azurepipeline-processor.jar
32-
ARG AZUREREPO_JAR_FILE=azure-repo/target/azurerepo-processor.jar
31+
ARG AZUREPIPELINE_JAR_FILE=azure-pipeline/target/azurepipeline-processor-exec.jar
32+
ARG AZUREREPO_JAR_FILE=azure-repo/target/azurerepo-processor-exec.jar
3333

3434
# Set the properties file names
3535
ARG AZUREPIPELINE_PROPERTIES_FILE_NAME=azurepipeline.properties

0 commit comments

Comments
 (0)