Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restructure project FE and BE #3

Merged
merged 12 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/ # Ensure it ends with a /
server-dir: /public_html/backend/ # Path where backend files are deployed on server
port: ${{ secrets.FTP_PORT }}
log-level: verbose
14 changes: 9 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# 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
/backend/.env

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

# Miscellaneous
/.angular/cache
/frontend/.angular/cache
.sass-cache/
/connect.lock
/coverage
Expand Down
Loading
Loading