Skip to content

Update main.yml #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
33 changes: 21 additions & 12 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
name: CICD
name: CICD-PIPELINE

on:
push:
branches: [main,master]
branches: [cicd-docker-ec2]

jobs:
build:
runs-on: [ubuntu-latest]
steps:
- name: Checkout Source
- name: Checkout source
uses: actions/checkout@v3
- name: Set Node.js 16.x
uses: actions/setup-node@v3
with:
node-version: 16.x
- name: Install Dependencies
run : npm install
- name: Test Project
run: npm test
- name: Login to docker hub
run: docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
- name: Build docker image
run: docker build -t integrationninjas/nodejs-app .
- name: Publish image to docker hub
run: docker push integrationninjas/nodejs-app:latest

deploy:
needs: build
runs-on: [runner-ec2]
steps:
- name: Pull image from docker hub
run: docker pull integrationninjas/nodejs-app:latest
- name: Delete old container
run: docker rm -f nodejs-app-container
- name: Run docker container
run: docker run -d -p 5000:5000 --name nodejs-app-container integrationninjas/nodejs-app