From f8576aedca62261a9e8efdd2ce2f0890a5a007f9 Mon Sep 17 00:00:00 2001 From: Geetesh Singh Date: Fri, 9 Jan 2026 23:54:20 +0530 Subject: [PATCH 1/8] Testing github actions --- .github/workflows/main.yml | 19 +++++++++++++++++++ .idea/.gitignore | 8 ++++++++ .idea/github-actions-demo-project.iml | 12 ++++++++++++ .idea/material_theme_project_new.xml | 13 +++++++++++++ .idea/modules.xml | 8 ++++++++ .idea/vcs.xml | 6 ++++++ package-lock.json | 6 ++++++ 7 files changed, 72 insertions(+) create mode 100644 .github/workflows/main.yml create mode 100644 .idea/.gitignore create mode 100644 .idea/github-actions-demo-project.iml create mode 100644 .idea/material_theme_project_new.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..5ba5d8c --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,19 @@ +name: Test Project + +on: + pull_request: + branches: + - main + +jobs: + test: + runs-on: ubuntu-latest + container: + image: node:20 + steps: + - uses: actions/checkout@v3 + with: + node-version: 20 + - run: npm ci + - run: npm test + - run: npm run build \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/github-actions-demo-project.iml b/.idea/github-actions-demo-project.iml new file mode 100644 index 0000000..24643cc --- /dev/null +++ b/.idea/github-actions-demo-project.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/material_theme_project_new.xml b/.idea/material_theme_project_new.xml new file mode 100644 index 0000000..4ceca5e --- /dev/null +++ b/.idea/material_theme_project_new.xml @@ -0,0 +1,13 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..7947ed3 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 32d28f8..7dade5e 100755 --- a/package-lock.json +++ b/package-lock.json @@ -72,6 +72,7 @@ "integrity": "sha512-BBt3opiCOxUr9euZ5/ro/Xv8/V7yJ5bjYMqG/C1YAo8MIKAnumZalCN+msbci3Pigy4lIQfPUpfMM27HMGaYEA==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@ampproject/remapping": "^2.2.0", "@babel/code-frame": "^7.24.7", @@ -2831,6 +2832,7 @@ "integrity": "sha512-49AbMDwYUz7EXxKU/r7mXOsxwFr4BYbvB7tWYxVuLdb2ibd30ijjXINSMAHiEEZk5PCRBmW1gUeisn2VMKt3cQ==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "undici-types": "~6.19.2" } @@ -3326,6 +3328,7 @@ } ], "license": "MIT", + "peer": true, "dependencies": { "caniuse-lite": "^1.0.30001646", "electron-to-chromium": "^1.5.4", @@ -4896,6 +4899,7 @@ "integrity": "sha512-NIy3oAFp9shda19hy4HK0HRTWKtPJmGdnvywu01nOqNC2vZg+Z+fvJDxpMQA88eb2I9EcafcdjYgsDthnYTvGw==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@jest/core": "^29.7.0", "@jest/types": "^29.6.3", @@ -7899,6 +7903,7 @@ "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@cspotcode/source-map-support": "^0.8.0", "@tsconfig/node10": "^1.0.7", @@ -7979,6 +7984,7 @@ "integrity": "sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==", "dev": true, "license": "Apache-2.0", + "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" From 049c7cabcb73d76d3092d940fddac338acbe6ef6 Mon Sep 17 00:00:00 2001 From: Geetesh Singh Date: Fri, 9 Jan 2026 23:56:48 +0530 Subject: [PATCH 2/8] Testing github actions --- src/index.ts | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/src/index.ts b/src/index.ts index 71ad74c..f596577 100755 --- a/src/index.ts +++ b/src/index.ts @@ -9,39 +9,41 @@ let server; // setup cors. app.use( - cors({ - origin: "*", - credentials: true, - optionSuccessStatus: 200, - }) + cors({ + origin: "*", + credentials: true, + optionSuccessStatus: 200, + }) ); // setup body parser. -app.use(body.json({ limit: "100kb" })); +app.use(body.json({limit: "100kb"})); // load all routes. app.use("/recipes", require("./routes/recipes")); async function startServer() { - try { - // Load express app to listen on config port. - const port = 3000 - server = app.listen(port, () => { - console.log(`Service ready on :${port}`) - }); - } catch (error) { - console.error("Failed to connect to the database:", error); - process.exit(1); - } + try { + // Load express app to listen on config port. + const port = 3000 + server = app.listen(port, () => { + console.log(`Service ready on :${port}`) + }); + } catch (error) { + console.error("Failed to connect to the database:", error); + process.exit(1); + } } function stop() { - console.log("Stopping server"); - server.close(); + console.log("Stopping server"); + server.close(); } -export { server, startServer, stop }; +export {server, startServer, stop}; -startServer(); \ No newline at end of file +startServer().then(r =>{ + +}); \ No newline at end of file From 89606338edfbe4befd7d881d7ec702eb23fb26a9 Mon Sep 17 00:00:00 2001 From: Geetesh Singh Date: Sat, 10 Jan 2026 00:24:31 +0530 Subject: [PATCH 3/8] Testing github actions --- .github/workflows/main.yml | 44 +++++++++++++++++++++++++++----------- Dockerfile | 22 +++++++++++++++++++ k8s-deployment.yaml | 31 +++++++++++++++++++++++++++ 3 files changed, 85 insertions(+), 12 deletions(-) create mode 100644 Dockerfile create mode 100644 k8s-deployment.yaml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5ba5d8c..fa23308 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,19 +1,39 @@ -name: Test Project +name: DevOps Pipeline CI/CD on: - pull_request: - branches: - - main + push: + branches: [ main ] jobs: - test: + deploy: runs-on: ubuntu-latest - container: - image: node:20 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + + # 1. CI: Build and Test + - name: Build and Test + run: | + npm ci + npm test + + # 2. Build Docker Image + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and Push + run: | + docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/demo-app:latest . + docker push ${{ secrets.DOCKERHUB_USERNAME }}/demo-app:latest + + # 3. CD: Deploy to Kubernetes + - name: Set K8s Context + uses: azure/k8s-set-context@v3 with: - node-version: 20 - - run: npm ci - - run: npm test - - run: npm run build \ No newline at end of file + method: kubeconfig + kubeconfig: ${{ secrets.KUBE_CONFIG }} + + - name: Deploy to Cluster + run: kubectl apply -f k8s-deployment.yaml \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0d32274 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +FROM ubuntu:latest +LABEL authors="geetesh" + +ENTRYPOINT ["top", "-b"] + +# Step 1: Build the app +FROM node:20 AS builder +WORKDIR /app +COPY package*.json ./ +RUN npm install +COPY . . +RUN npm run build + +# Step 2: Run the app +FROM node:20-slim +WORKDIR /app +COPY --from=builder /app/dist ./dist +COPY --from=builder /app/package*.json ./ +RUN npm install --only=production + +EXPOSE 3000 +CMD ["node", "dist/index.js"] \ No newline at end of file diff --git a/k8s-deployment.yaml b/k8s-deployment.yaml new file mode 100644 index 0000000..0a3146e --- /dev/null +++ b/k8s-deployment.yaml @@ -0,0 +1,31 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: demo-app +spec: + replicas: 2 + selector: + matchLabels: + app: demo + template: + metadata: + labels: + app: demo + spec: + containers: + - name: demo-app + image: geeteshs/demo-app:latest + ports: + - containerPort: 3000 +--- +apiVersion: v1 +kind: Service +metadata: + name: demo-service +spec: + type: LoadBalancer + selector: + app: demo + ports: + - port: 80 + targetPort: 3000 \ No newline at end of file From 43e92cee678c217af5e603067ecb699144dc3b0e Mon Sep 17 00:00:00 2001 From: Geetesh Singh Date: Sat, 10 Jan 2026 00:28:57 +0530 Subject: [PATCH 4/8] Testing github actions --- .github/workflows/main.yml | 40 ++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fa23308..377e1f6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,39 +1,49 @@ -name: DevOps Pipeline CI/CD +name: Full DevOps Flow on: push: branches: [ main ] jobs: - deploy: + build-and-push: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - # 1. CI: Build and Test - - name: Build and Test - run: | - npm ci - npm test + # 1. Setup Node and Test + - name: Install Dependencies + run: npm ci + - name: Run Tests + run: npm test - # 2. Build Docker Image + # 2. Build and Push to Docker Hub - name: Login to Docker Hub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and Push - run: | - docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/demo-app:latest . - docker push ${{ secrets.DOCKERHUB_USERNAME }}/demo-app:latest + - name: Build and Push Docker Image + uses: docker/build-push-action@v5 + with: + context: . + push: true + # Replace 'geetesh' with your actual Docker Hub username + tags: ${{ secrets.DOCKERHUB_USERNAME }}/github-actions-demo:latest + + deploy-local: + needs: build-and-push + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 - # 3. CD: Deploy to Kubernetes - - name: Set K8s Context + - name: Set Kubernetes Context uses: azure/k8s-set-context@v3 with: method: kubeconfig kubeconfig: ${{ secrets.KUBE_CONFIG }} - - name: Deploy to Cluster + - name: Deploy to K8s + # This will fail until your K8s cluster is reachable from the internet + # But it's the correct way to write the script! run: kubectl apply -f k8s-deployment.yaml \ No newline at end of file From bb9172c71282413765d233d5f3392ecad27bab9c Mon Sep 17 00:00:00 2001 From: Geetesh Singh Date: Sat, 10 Jan 2026 00:35:36 +0530 Subject: [PATCH 5/8] Testing github actions --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 377e1f6..2c2e766 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,7 +2,7 @@ name: Full DevOps Flow on: push: - branches: [ main ] + branches: [ main, feature-test-pipeline ] jobs: build-and-push: From f540401eb1ace18ec9fdace50b24888ad862b965 Mon Sep 17 00:00:00 2001 From: Geetesh Singh Date: Sat, 10 Jan 2026 01:09:42 +0530 Subject: [PATCH 6/8] Testing github actions --- k8s-deployment.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/k8s-deployment.yaml b/k8s-deployment.yaml index 0a3146e..a5e1543 100644 --- a/k8s-deployment.yaml +++ b/k8s-deployment.yaml @@ -14,7 +14,7 @@ spec: spec: containers: - name: demo-app - image: geeteshs/demo-app:latest + image: geeteshs/github-actions-demo:latest ports: - containerPort: 3000 --- From 09b58c09cd3d9de1cfa7354ccd73cc63246979f9 Mon Sep 17 00:00:00 2001 From: Geetesh Singh Date: Sat, 10 Jan 2026 10:49:15 +0530 Subject: [PATCH 7/8] Testing github actions --- .idea/dictionaries/project.xml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .idea/dictionaries/project.xml diff --git a/.idea/dictionaries/project.xml b/.idea/dictionaries/project.xml new file mode 100644 index 0000000..a3dd187 --- /dev/null +++ b/.idea/dictionaries/project.xml @@ -0,0 +1,7 @@ + + + + geeteshs + + + \ No newline at end of file From 2a9a06ab2a960e09e84b3bda25cfeb3537dd1f75 Mon Sep 17 00:00:00 2001 From: Geetesh Singh Date: Sat, 10 Jan 2026 10:50:58 +0530 Subject: [PATCH 8/8] Testing github actions --- .github/workflows/main.yml | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2c2e766..c10a4cc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -31,19 +31,19 @@ jobs: # Replace 'geetesh' with your actual Docker Hub username tags: ${{ secrets.DOCKERHUB_USERNAME }}/github-actions-demo:latest - deploy-local: - needs: build-and-push - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Set Kubernetes Context - uses: azure/k8s-set-context@v3 - with: - method: kubeconfig - kubeconfig: ${{ secrets.KUBE_CONFIG }} - - - name: Deploy to K8s - # This will fail until your K8s cluster is reachable from the internet - # But it's the correct way to write the script! - run: kubectl apply -f k8s-deployment.yaml \ No newline at end of file +# deploy-local: +# needs: build-and-push +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v4 +# +# - name: Set Kubernetes Context +# uses: azure/k8s-set-context@v3 +# with: +# method: kubeconfig +# kubeconfig: ${{ secrets.KUBE_CONFIG }} +# +# - name: Deploy to K8s +# # This will fail until your K8s cluster is reachable from the internet +# # But it's the correct way to write the script! +# run: kubectl apply -f k8s-deployment.yaml \ No newline at end of file