Skip to content

Commit

Permalink
workflow editted
Browse files Browse the repository at this point in the history
  • Loading branch information
Luxshan2000 committed Sep 28, 2023
1 parent 5e16061 commit afdfed0
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 66 deletions.
32 changes: 0 additions & 32 deletions .github/workflows/backend.yml

This file was deleted.

34 changes: 0 additions & 34 deletions .github/workflows/frontend.yml

This file was deleted.

57 changes: 57 additions & 0 deletions .github/workflows/workflow.yml
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

0 comments on commit afdfed0

Please sign in to comment.