Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: hello-node-ci
on:
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
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
uses: docker/build-push-action@v6
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 "[email protected]"
# 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
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM node:18
WORKDIR /usr/src/app
COPY package.json .
RUN npm i
COPY . .
CMD ["node","index.js"]
EXPOSE 3000
21 changes: 21 additions & 0 deletions kubernetes/deployment.yaml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions node-hello
Submodule node-hello added at 987103