Skip to content

Commit

Permalink
Restructure project - adding frontend and backend
Browse files Browse the repository at this point in the history
  • Loading branch information
rotirk20 committed Sep 20, 2024
1 parent 178ef6e commit ae7381d
Show file tree
Hide file tree
Showing 57 changed files with 955 additions and 28 deletions.
93 changes: 70 additions & 23 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,63 +3,110 @@ name: CI/CD Pipeline
on:
push:
branches:
- main # Trigger deployment only on push to main
- main # Trigger deployment only on push to the main branch
pull_request:
branches:
- main # Run build checks on PRs but don't deploy
- main # Run checks on PRs, but don't deploy

jobs:
build:
# --- Build Frontend ---
build-frontend:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Node.js

- name: Set up Node.js for frontend
uses: actions/setup-node@v3
with:
node-version: '20' # specify the Node.js version
node-version: '20' # Specify the Node.js version

- name: Install dependencies
- name: Install frontend dependencies
working-directory: ./frontend # Navigate to the frontend folder
run: npm install

# Optional: Uncomment if you want to run tests
# - name: Run tests
# run: npm test -- --watch=false --browsers=ChromeHeadless

- name: Build project
- name: Build frontend
working-directory: ./frontend
run: npm run build

- name: Upload artifact
- name: Upload frontend artifact
uses: actions/upload-artifact@v4
with:
name: angular-build
path: "./dist/smetovi/"
path: ./frontend/dist/ # Path to Angular build files

deploy:
# Deploy only when a push is made directly to the main branch
if: github.ref == 'refs/heads/main' # Ensure deployment happens only on push to main
needs: build
# --- Build Backend ---
build-backend:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Download artifact
- name: Set up Node.js for backend
uses: actions/setup-node@v3
with:
node-version: '20' # Specify the Node.js version

- name: Install backend dependencies
working-directory: ./backend # Navigate to the backend folder
run: npm install

- name: Upload backend artifact
uses: actions/upload-artifact@v4
with:
name: backend-artifact
path: ./backend # Upload the backend folder for deployment

# --- Deploy Frontend ---
deploy-frontend:
runs-on: ubuntu-latest
needs: build-frontend # Ensure the frontend build completes before deployment

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Download frontend artifact
uses: actions/download-artifact@v4
with:
name: angular-build
path: "./dist/smetovi/"
path: ./frontend/dist/ # Download the Angular build

- name: Deploy frontend to cPanel via FTP
uses: SamKirkland/[email protected]
with:
server: ${{ secrets.FTP_SERVER }}
username: ${{ secrets.FTP_USERNAME }}
password: ${{ secrets.FTP_PASSWORD }}
local-dir: ./frontend/dist/ # Adjust this to match your project build output
server-dir: /public_html/frontend/ # Path where frontend files are deployed on server
port: ${{ secrets.FTP_PORT }}
log-level: verbose

# --- Deploy Backend ---
deploy-backend:
runs-on: ubuntu-latest
needs: build-backend # Ensure the backend build completes before deployment

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Download backend artifact
uses: actions/download-artifact@v4
with:
name: backend-artifact
path: ./backend # Download the backend code

- name: Deploy to cPanel hosting via FTP
- name: Deploy backend to cPanel via FTP
uses: SamKirkland/[email protected]
with:
server: ${{ secrets.FTP_SERVER }}
username: ${{ secrets.FTP_USERNAME }}
password: ${{ secrets.FTP_PASSWORD }}
local-dir: ./dist/smetovi/ # Adjust this to match your project build output
server-dir: /public_html/ # Adjust this to your target directory on the server
local-dir: ./backend # Deploy the entire backend folder
server-dir: /public_html/backend/ # Path where backend files are deployed on server
port: ${{ secrets.FTP_PORT }}
log-level: verbose
13 changes: 8 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# Compiled output
/dist
/tmp
/out-tsc
/bazel-out
/frontend/dist
/frontend/tmp
/frontend/node_modules
/frontend/out-tsc
/frontend/bazel-out
/backend/node_modules
/backend/tmp

# Node
/node_modules
Expand All @@ -29,7 +32,7 @@ yarn-error.log
.history/*

# Miscellaneous
/.angular/cache
/frontend/.angular/cache
.sass-cache/
/connect.lock
/coverage
Expand Down
5 changes: 5 additions & 0 deletions backend/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=
DB_NAME=smetovi
DB_PORT=4000
Loading

0 comments on commit ae7381d

Please sign in to comment.