testing ci/cd pipeline #3
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
name: CICD | |
on: | |
push: | |
branches: [main] | |
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.DOCKER_PASSWORD}} | |
- name: Build docker image | |
run: docker build -t jayantvashisth/furniturebackend . | |
- name: Publish image to docker hub | |
run: docker push jayantvashisth/furniturebackend:latest | |
deploy: | |
needs: build | |
runs-on: [aws-ec2] | |
steps: | |
- name: Pull image from docker hub | |
run: docker pull jayantvashisth/furniturebackend | |
- name: Delete old container | |
run: docker rm -f furniture-container | |
- name: Run docker container | |
run: docker run -d -p 5000:5000 --name furniture-container jayantvashisth/furniturebackend |