From 3beab6b5df3ffc68c4ed8805adb71fc726ee6d3e Mon Sep 17 00:00:00 2001 From: Muzammil-2 <109243844+Muzammil-2@users.noreply.github.com> Date: Thu, 28 Aug 2025 12:45:29 +0000 Subject: [PATCH 01/15] ci.yaml file updates --- .github/workflows/ci.yaml | 15 +++++++++++++++ Dockerfile | 7 +++++++ 2 files changed, 22 insertions(+) create mode 100644 .github/workflows/ci.yaml create mode 100644 Dockerfile diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 000000000..c76355dfe --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,15 @@ +name: node-hello-ci + +on: + pull_request: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: checkout-codes + uses: actions/checkout@4 + \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..d47ad7918 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM node:18 +WORKDIR /usr/src/app +COPY package.json . +RUN npm i +COPY . . +CMD ["node","index.js"] +EXPOSE 3000 \ No newline at end of file From 6c6036a88c2baeb64fa9aef91cfdc5f46e5395c8 Mon Sep 17 00:00:00 2001 From: Muzammil-2 <109243844+Muzammil-2@users.noreply.github.com> Date: Thu, 28 Aug 2025 18:23:14 +0530 Subject: [PATCH 02/15] Update ci.yaml --- .github/workflows/ci.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c76355dfe..13183ef4f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -3,7 +3,7 @@ name: node-hello-ci on: pull_request: branches: - - main + - master jobs: build: @@ -12,4 +12,4 @@ jobs: steps: - name: checkout-codes uses: actions/checkout@4 - \ No newline at end of file + From 615981cf1894db4aa26d43c1d6289093247acff8 Mon Sep 17 00:00:00 2001 From: Muzammil-2 <109243844+Muzammil-2@users.noreply.github.com> Date: Thu, 28 Aug 2025 18:30:42 +0530 Subject: [PATCH 03/15] Update ci.yaml --- .github/workflows/ci.yaml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 13183ef4f..2c8013af7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,15 +1,15 @@ -name: node-hello-ci -on: - pull_request: +name: product-catalog-ci + +on: + pull_request: branches: - - master + - main jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-latest - steps: - - name: checkout-codes - uses: actions/checkout@4 - + steps: + - name: checkout code + uses: actions/checkout@v4 From 1811b4fc18e690e8ea13927dc555f1a1c6fa8e61 Mon Sep 17 00:00:00 2001 From: Muzammil-2 <109243844+Muzammil-2@users.noreply.github.com> Date: Thu, 28 Aug 2025 18:37:21 +0530 Subject: [PATCH 04/15] Update ci.yaml --- .github/workflows/ci.yaml | 41 +++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2c8013af7..228e9d676 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,15 +1,36 @@ -name: product-catalog-ci +name: Node.js CI -on: - pull_request: - branches: - - main +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] jobs: - build: - runs-on: ubuntu-latest + build: + runs-on: ubuntu-latest - steps: - - name: checkout code - uses: actions/checkout@v4 + steps: + # 1. Checkout repo code + - name: Checkout code + uses: actions/checkout@v3 + + # 2. Setup Node.js (choose version) + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: '18' # Change to your version (e.g., 16, 20) + cache: 'npm' # Enable caching for faster builds + + # 3. Install dependencies + - name: Install dependencies + run: npm install + + # # 4. Run tests + # - name: Run tests + # run: npm test + + # 5. (Optional) Build project + - name: Build project + run: npm run build From b047ce18b6e3b0bca1375213185d0e19959fd73f Mon Sep 17 00:00:00 2001 From: Muzammil-2 <109243844+Muzammil-2@users.noreply.github.com> Date: Thu, 28 Aug 2025 18:38:58 +0530 Subject: [PATCH 05/15] Update ci.yaml --- .github/workflows/ci.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 228e9d676..3a913a1f9 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -3,9 +3,9 @@ name: Node.js CI on: push: - branches: [ "main" ] + branches: [ "master" ] pull_request: - branches: [ "main" ] + branches: [ "master" ] jobs: build: From ce6c8276bc4f3931d36cc973b364adbecb17396f Mon Sep 17 00:00:00 2001 From: Muzammil-2 <109243844+Muzammil-2@users.noreply.github.com> Date: Thu, 28 Aug 2025 18:40:13 +0530 Subject: [PATCH 06/15] Update ci.yaml --- .github/workflows/ci.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3a913a1f9..c37bf6173 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -32,5 +32,5 @@ jobs: # run: npm test # 5. (Optional) Build project - - name: Build project - run: npm run build + # - name: Build project + # run: npm run build From 15a8425e18cba7526203b7ef4a509f3dabfdd5e8 Mon Sep 17 00:00:00 2001 From: Muzammil-2 <109243844+Muzammil-2@users.noreply.github.com> Date: Thu, 28 Aug 2025 18:42:23 +0530 Subject: [PATCH 07/15] Update ci.yaml --- .github/workflows/ci.yaml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c37bf6173..ec5123cb1 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -34,3 +34,23 @@ jobs: # 5. (Optional) Build project # - name: Build project # run: npm run build + + code-quality: + runs-on: ubuntu-latest + needs: build # Run after build + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: '18' + cache: 'npm' + + - name: Install dependencies + run: npm install + + # Example with ESLint + - name: Run ESLint + run: npm run lint From dea76775ad0123ba8bb450a486448020560c6c25 Mon Sep 17 00:00:00 2001 From: Muzammil-2 <109243844+Muzammil-2@users.noreply.github.com> Date: Fri, 29 Aug 2025 00:45:30 +0530 Subject: [PATCH 08/15] Update ci.yaml --- .github/workflows/ci.yaml | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ec5123cb1..63c1b4d91 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -35,22 +35,4 @@ jobs: # - name: Build project # run: npm run build - code-quality: - runs-on: ubuntu-latest - needs: build # Run after build - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Setup Node.js - uses: actions/setup-node@v3 - with: - node-version: '18' - cache: 'npm' - - - name: Install dependencies - run: npm install - - # Example with ESLint - - name: Run ESLint - run: npm run lint + From 532ccdca2db2b0742bfb0e5b775b9bb5e2182330 Mon Sep 17 00:00:00 2001 From: Muzammil-2 <109243844+Muzammil-2@users.noreply.github.com> Date: Thu, 28 Aug 2025 19:53:57 +0000 Subject: [PATCH 09/15] ci update --- .github/workflows/ci.yaml | 106 ++++++++++++++++++++++++++++++++++--- Dockerfile | 2 +- kubernetes/deployment.yaml | 21 ++++++++ 3 files changed, 120 insertions(+), 9 deletions(-) create mode 100644 kubernetes/deployment.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c76355dfe..bf1fd1dec 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,15 +1,105 @@ -name: node-hello-ci +# CI for hello-node Service + +name: product-catalog-ci on: - pull_request: - branches: - - main + push: + branches: [ "main" ] jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-latest + + steps: + # checkout codes + - name: checkout code + uses: actions/checkout@v4 + # setup node + - name: Setup node 18 + uses: actions/setup-node@v3 + with: + node-version: 18 + + - name: Build + run: | + npm install + + + - name: unit tests + run: | + npm test + + # code-quality: + # runs-on: ubuntu-latest + + # steps: + # - name: checkout code + # uses: actions/checkout@v4 + + # - name: Setup node 18 + # uses: actions/setup-node@v3 + # with: + # node-version: 18 + + # - name: Run eslint + # uses: eslint/eslint-action@v2 + # with: + # eslint-version: latest + # working-directory: s + + docker: + runs-on: ubuntu-latest + + needs: build + + steps: + - name: checkout code + uses: actions/checkout@v4 + + - name: Install Docker + uses: docker/setup-buildx-action@v1 + + - name: Login to Docker + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_TOKEN }} + + - name: Docker Push + uses: docker/build-push-action@v6 + with: + context: . + file: ./Dockerfile + push: true + tags: ${{ secrets.DOCKER_USERNAME }}/product-catalog:${{github.run_id}} + + + updatek8s: + runs-on: ubuntu-latest + + needs: docker + + steps: + - name: checkout code + uses: actions/checkout@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Update tag in kubernetes deployment manifest + run: | + sed -i "s|image: .*|image: ${{ secrets.DOCKER_USERNAME }}/node-hello:${{github.run_id}}|" kubernetes/deployment.yaml + + - name: Commit and push changes + run: | + git config --global user.email "muzammil01vivek@gmail.com" + git config --global user.name "Muzammil-2" + git add . + git commit -m "[CI]: Update product catalog image tag" + git push origin HEAD:main -f + + + + + - steps: - - name: checkout-codes - uses: actions/checkout@4 \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index d47ad7918..21ef28881 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,4 +4,4 @@ COPY package.json . RUN npm i COPY . . CMD ["node","index.js"] -EXPOSE 3000 \ No newline at end of file +EXPOSE 3000 diff --git a/kubernetes/deployment.yaml b/kubernetes/deployment.yaml new file mode 100644 index 000000000..57f0ac469 --- /dev/null +++ b/kubernetes/deployment.yaml @@ -0,0 +1,21 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: nginx-deployment + labels: + app: nginx +spec: + replicas: 3 + selector: + matchLabels: + app: nginx + template: + metadata: + labels: + app: nginx + spec: + containers: + - name: nginx + image: quadrimuzammil/node-hello:${{github.run_id}} + ports: + - containerPort: 80 From a1dafda3363179969574d48544c47b9cda412348 Mon Sep 17 00:00:00 2001 From: Muzammil-2 <109243844+Muzammil-2@users.noreply.github.com> Date: Thu, 28 Aug 2025 19:55:29 +0000 Subject: [PATCH 10/15] ci update with branch name --- .github/workflows/ci.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index bf1fd1dec..fe0736e0c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -4,7 +4,7 @@ name: product-catalog-ci on: push: - branches: [ "main" ] + branches: [ "master" ] jobs: build: @@ -25,9 +25,9 @@ jobs: npm install - - name: unit tests - run: | - npm test + # - name: unit tests + # run: | + # npm test # code-quality: # runs-on: ubuntu-latest From fd44a3a0f7c249e5e274c5af59eb92de86dd1fb0 Mon Sep 17 00:00:00 2001 From: Muzammil-2 <109243844+Muzammil-2@users.noreply.github.com> Date: Thu, 28 Aug 2025 20:17:08 +0000 Subject: [PATCH 11/15] update ci yaml --- .github/workflows/ci.yaml | 109 ++++++++++++++++++++++++++------------ 1 file changed, 74 insertions(+), 35 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c13f4d2c5..71fac51d8 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,39 +1,78 @@ - -name: Node.js CI - name: product-catalog-ci on: - push: - branches: [ "master" ] - pull_request: - branches: [ "master" ] + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] jobs: - build: - runs-on: ubuntu-latest - - steps: - # 1. Checkout repo code - - name: Checkout code - uses: actions/checkout@v3 - - # 2. Setup Node.js (choose version) - - name: Setup Node.js - uses: actions/setup-node@v3 - with: - node-version: '18' # Change to your version (e.g., 16, 20) - cache: 'npm' # Enable caching for faster builds - - # 3. Install dependencies - - name: Install dependencies - run: npm install - - # # 4. Run tests - # - name: Run tests - # run: npm test - - # 5. (Optional) Build project - # - name: Build project - # run: npm run build - - + build: + runs-on: ubuntu-latest + + steps: + # 1. Checkout repo code + - name: Checkout code + uses: actions/checkout@v3 + + # 2. Setup Node.js (choose version) + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: '18' # Change to your version (e.g., 16, 20) + cache: 'npm' # Enable caching for faster builds + + # 3. Install dependencies + - name: Install dependencies + run: npm install + + # # 4. Run tests + # - name: Run tests + # run: npm test + + # 5. (Optional) Build project + # - name: Build project + # run: npm run build + docker: + runs-on: ubuntu-latest + + needs: build + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Install Docker + uses: docker/setup-buildx-action@v2 + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_TOKEN }} + - name: docker push + with: + context: . + file: ./Dockerfile + push: true + tags: ${{ secrets.DOCKER_USERNAME }}/hello-node:${{ github.run_id }} + + # updatek8s: + # runs-on: ubuntu-latest + + # needs: docker + + # steps: + # - name: checkout code + # uses: actions/checkout@v4 + # with: + # token: ${{ secrets.GITHUB_TOKEN }} + + # - name: Update tag in kubernetes deployment manifest + # run: | + # sed -i "s|image: .*|image: ${{ secrets.DOCKER_USERNAME }}/node-hello:${{github.run_id}}|" kubernetes/deployment.yaml + + # - name: Commit and push changes + # run: | + # git config --global user.email "abhishek@gmail.com" + # git config --global user.name "Abhishek Veeramalla" + # git add kubernetes/productcatalog/deploy.yaml + # git commit -m "[CI]: Update product catalog image tag" + # git push origin HEAD:main -f From 39934a4f1a08f6fabc5717e93c25f48e9030e68d Mon Sep 17 00:00:00 2001 From: Muzammil-2 <109243844+Muzammil-2@users.noreply.github.com> Date: Thu, 28 Aug 2025 20:28:24 +0000 Subject: [PATCH 12/15] indendation in ci --- .github/workflows/ci.yaml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 71fac51d8..9f599ccbc 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -33,10 +33,10 @@ jobs: # - name: Build project # run: npm run build docker: - runs-on: ubuntu-latest + runs-on: ubuntu-latest - needs: build - steps: + needs: build + steps: - name: Checkout code uses: actions/checkout@v3 @@ -47,12 +47,12 @@ jobs: with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_TOKEN }} - - name: docker push - with: - context: . - file: ./Dockerfile - push: true - tags: ${{ secrets.DOCKER_USERNAME }}/hello-node:${{ github.run_id }} + - name: docker push + with: + context: . + file: ./Dockerfile + push: true + tags: ${{ secrets.DOCKER_USERNAME }}/hello-node:${{ github.run_id }} # updatek8s: # runs-on: ubuntu-latest From 9610f08e926abfe7529c41f6a4719c592ce6845e Mon Sep 17 00:00:00 2001 From: Muzammil-2 <109243844+Muzammil-2@users.noreply.github.com> Date: Thu, 28 Aug 2025 20:31:19 +0000 Subject: [PATCH 13/15] add missed uses in docker push step --- .github/workflows/ci.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9f599ccbc..2eaedc177 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -48,6 +48,7 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_TOKEN }} - name: docker push + uses: docker/build-push-action@v6 with: context: . file: ./Dockerfile From 987103830720e1b5bcbf6d3894ff5b61bb09b0de Mon Sep 17 00:00:00 2001 From: Muzammil-2 <109243844+Muzammil-2@users.noreply.github.com> Date: Thu, 28 Aug 2025 20:37:06 +0000 Subject: [PATCH 14/15] update name of ci --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2eaedc177..dc1468bfb 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,4 +1,4 @@ -name: product-catalog-ci +name: hello-node-ci on: push: branches: [ "master" ] From 5b0b6aead21d5acb357100455b1b354ec643c982 Mon Sep 17 00:00:00 2001 From: Muzammil-2 <109243844+Muzammil-2@users.noreply.github.com> Date: Mon, 1 Sep 2025 09:42:46 +0000 Subject: [PATCH 15/15] up index.js --- node-hello | 1 + 1 file changed, 1 insertion(+) create mode 160000 node-hello diff --git a/node-hello b/node-hello new file mode 160000 index 000000000..987103830 --- /dev/null +++ b/node-hello @@ -0,0 +1 @@ +Subproject commit 987103830720e1b5bcbf6d3894ff5b61bb09b0de