-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d453461
commit 1f1c367
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
nodejs-app-cicd-docker-ec2/.github/workflows/cicd-workflow.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: CI-CD | ||
|
||
on: | ||
push: | ||
branches: ['master'] | ||
|
||
jobs: | ||
build: | ||
runs-on: [ubuntu-latest] | ||
steps: | ||
- name: Checkout source | ||
uses: actions/checkout@v3 | ||
- name: Login to Docker Hub | ||
run: docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{secrets.DOKCER_PASSWORD}} | ||
- name: Build Docker image | ||
run: docker build -t pawansoni007/node-app_github_actions . | ||
- name: Publish image to Docker Hub | ||
run: docker push pawansoni007/node-app_github_actions:latest | ||
|
||
deploy: | ||
needs: build | ||
runs-on: [azure-node] | ||
steps: | ||
- name: Pull image from docker hub | ||
run: docker pull pawansoni007/node-app_github_actions:latest | ||
- name: Delete old container | ||
run: docker rm -f node-app-container | ||
- name: Run a docker container | ||
run: docker run -d -p 4000:4000 -name node-app-container pawansoni007/node-app_github_actions:latest |