Add package lock files and fix GitHub Actions workflow #3
This file contains hidden or 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: BuildEstate CI/CD | |
on: | |
push: | |
branches: [ main, master ] | |
pull_request: | |
branches: [ main, master ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [18.x] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
# Either specify a package manager for caching or remove cache parameter completely | |
# cache: 'npm' # Uncomment this line if you want to enable npm caching | |
# Generate lock files first (if they don't exist) | |
- name: Generate lock files | |
run: | | |
# Check and create package-lock.json files if needed | |
[ ! -f ./package-lock.json ] && npm install --package-lock-only || echo "Root lock file exists" | |
[ ! -f ./backend/package-lock.json ] && cd backend && npm install --package-lock-only && cd .. || echo "Backend lock file exists" | |
[ ! -f ./frontend/package-lock.json ] && cd frontend && npm install --package-lock-only && cd .. || echo "Frontend lock file exists" | |
[ ! -f ./admin/package-lock.json ] && cd admin && npm install --package-lock-only && cd .. || echo "Admin lock file exists" | |
# Install dependencies | |
- name: Install root dependencies | |
run: npm ci || npm install # Try npm ci first, fall back to npm install | |
- name: Install backend dependencies | |
working-directory: ./backend | |
run: npm ci || npm install | |
- name: Install frontend dependencies | |
working-directory: ./frontend | |
run: npm ci || npm install | |
- name: Install admin dependencies | |
working-directory: ./admin | |
run: npm ci || npm install | |
- name: Lint backend | |
working-directory: ./backend | |
run: npm run lint || echo "No lint script found" | |
- name: Lint frontend | |
working-directory: ./frontend | |
run: npm run lint || echo "No lint script found" | |
- name: Lint admin | |
working-directory: ./admin | |
run: npm run lint || echo "No lint script found" | |
- name: Build frontend | |
working-directory: ./frontend | |
run: npm run build | |
- name: Build admin dashboard | |
working-directory: ./admin | |
run: npm run build |