-
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
5e16061
commit afdfed0
Showing
3 changed files
with
57 additions
and
66 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,57 @@ | ||
name: CICD | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build-frontend: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout source | ||
uses: actions/checkout@v2 | ||
|
||
- name: Build and push frontend Docker image | ||
run: | | ||
cd frontend | ||
docker build -t luxshan/frontend:latest . | ||
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | ||
docker push luxshan/frontend:latest | ||
build-backend: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout source | ||
uses: actions/checkout@v2 | ||
|
||
- name: Build and push backend Docker image | ||
run: | | ||
cd backend | ||
docker build -t luxshan/backend:latest . | ||
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | ||
docker push luxshan/backend:latest | ||
deploy: | ||
needs: [build-frontend, build-backend] | ||
runs-on: self-hosted | ||
steps: | ||
- name: Pull frontend and backend images from Docker Hub | ||
run: | | ||
docker pull luxshan/frontend:latest | ||
docker pull luxshan/backend:latest | ||
- name: Stop and remove old containers | ||
run: | | ||
docker stop frontend-container || true | ||
docker rm frontend-container || true | ||
docker stop backend-container || true | ||
docker rm backend-container || true | ||
- name: Run frontend container | ||
run: | | ||
docker run -d -p 3000:3000 --name frontend-container luxshan/frontend:latest | ||
- name: Run backend container | ||
run: | | ||
docker run -d -p 5000:5000 --name backend-container luxshan/backend:latest |