Skip to content

Feature/improve bboxselector performance (#1) #25

Feature/improve bboxselector performance (#1)

Feature/improve bboxselector performance (#1) #25

name: Build and deploy
on:
push:
branches:
- main # Trigger on push to main branch
workflow_dispatch: # Allow manual trigger
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 'lts/*' # Latest LTS version
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
- name: Enable Corepack
run: corepack enable
- name: Install dependencies
run: npm ci
working-directory: ./
- name: Build project
run: npm run build
working-directory: ./
- name: Deploy to docs branch
run: |
# Configure Git
git config --global user.name "GitHub Actions Bot"
git config --global user.email "github-actions-bot@users.noreply.github.com"
# Save build files to a temporary location
mkdir -p /tmp/build-files
cp -r ./packages/stlmaps-app/dist/* /tmp/build-files
# Check if docs branch exists
if git ls-remote --heads origin docs | grep docs; then
# Branch exists, check it out
git fetch origin docs
git checkout docs
else
# Branch doesn't exist, create an orphan branch
git checkout --orphan docs
git reset --hard
fi
# Remove old files but keep .git
find . -maxdepth 1 ! -name '.git' ! -name '.' -exec rm -rf {} \;
# Copy build files from temporary location to root
cp -r /tmp/build-files/* .
# Add and commit changes
git add -A
git commit -m "Deploy: $(date +%Y-%m-%d_%H-%M-%S)" || echo "No changes to commit"
# Push to docs branch
git push -f origin docs