Skip to content

Commit

Permalink
updated flow file
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuldeep-knoldus committed Jul 16, 2024
1 parent 414325e commit fca99c4
Showing 1 changed file with 64 additions and 54 deletions.
118 changes: 64 additions & 54 deletions .github/workflows/gcp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,43 +15,43 @@ env:
GOOGLE_GEMINI_API_KEY: ${{ secrets.GOOGLE_GEMINI_API_KEY }}

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

# Set up JDK for Java projects
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: maven

# Set up Node.js for Angular projects
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '21'

# Build Java and Angular projects
- name: Build Projects
run: |
SERVICE_NAMES=$(cat projects-changes-deploy.txt)
echo "Service Names: $SERVICE_NAMES"
for SERVICE_NAME in $(echo $SERVICE_NAMES | tr ',' ' '); do
echo "Building $SERVICE_NAME"
if [ -d "$SERVICE_NAME" ]; then
cd $SERVICE_NAME
if [ "$SERVICE_NAME" == "blogs-analyzer-ui" ]; then
npm install && npm test && npm install -g sonarqube-scanner && npm run sonar
else
mvn clean install -Psonar -B -V
fi
cd ..
fi
done
# build:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v4
#
# # Set up JDK for Java projects
# - name: Set up JDK 21
# uses: actions/setup-java@v4
# with:
# java-version: '21'
# distribution: 'temurin'
# cache: maven
#
# # Set up Node.js for Angular projects
# - name: Set up Node.js
# uses: actions/setup-node@v4
# with:
# node-version: '21'
#
# # Build Java and Angular projects
# - name: Build Projects
# run: |
# SERVICE_NAMES=$(cat projects-changes-deploy.txt)
# echo "Service Names: $SERVICE_NAMES"
# for SERVICE_NAME in $(echo $SERVICE_NAMES | tr ',' ' '); do
# echo "Building $SERVICE_NAME"
# if [ -d "$SERVICE_NAME" ]; then
# cd $SERVICE_NAME
# if [ "$SERVICE_NAME" == "blogs-analyzer-ui" ]; then
# npm install && npm test && npm install -g sonarqube-scanner && npm run sonar
# else
# mvn clean install -Psonar -B -V
# fi
# cd ..
# fi
# done

deploy:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -89,25 +89,35 @@ jobs:
java-version: '21'
distribution: 'temurin'
cache: maven
#
# - name: Build and Push Docker Images
# run: |
# COMMIT_SHA=$(git rev-parse --short HEAD)
# SERVICE_NAMES=$(cat projects-changes-deploy.txt)
# echo "Service Names: $SERVICE_NAMES"
# for SERVICE_NAME in $(echo $SERVICE_NAMES | tr ',' ' '); do
# echo "Building and pushing Docker image for $SERVICE_NAME"
# if [ -d "$SERVICE_NAME" ]; then
# cd $SERVICE_NAME
# if [ "$SERVICE_NAME" != "blogs-analyzer-ui" ]; then
# mvn clean install -DskipTests
# fi
# IMAGE_NAME=gcr.io/gen-lang-client-0999974873/$SERVICE_NAME:$COMMIT_SHA
# docker build -t $IMAGE_NAME .
# docker push $IMAGE_NAME
# cd ..
# fi
# done

- name: Build and Push Docker Images
- name: Check environment variables
run: |
COMMIT_SHA=$(git rev-parse --short HEAD)
SERVICE_NAMES=$(cat projects-changes-deploy.txt)
echo "Service Names: $SERVICE_NAMES"
for SERVICE_NAME in $(echo $SERVICE_NAMES | tr ',' ' '); do
echo "Building and pushing Docker image for $SERVICE_NAME"
if [ -d "$SERVICE_NAME" ]; then
cd $SERVICE_NAME
if [ "$SERVICE_NAME" != "blogs-analyzer-ui" ]; then
mvn clean install -DskipTests
fi
IMAGE_NAME=gcr.io/gen-lang-client-0999974873/$SERVICE_NAME:$COMMIT_SHA
docker build -t $IMAGE_NAME .
docker push $IMAGE_NAME
cd ..
fi
done
echo "PROJECT_ID=$PROJECT_ID"
echo "SERVICE_ACCOUNT_KEY=$SERVICE_ACCOUNT_KEY"
echo "CLUSTER_NAME=$CLUSTER_NAME"
echo "REGION=$REGION"
echo "REGISTRY_NAME=$REGISTRY_NAME"
echo "SONAR_TOKEN=$SONAR_TOKEN"
echo "GOOGLE_GEMINI_API_KEY=$GOOGLE_GEMINI_API_KEY"
- name: Deploy to GKE
run: |
Expand Down

0 comments on commit fca99c4

Please sign in to comment.