Feat: Enhance Gitea Actions with linting, PR triggers, and separate deploy job
This commit is contained in:
@ -1,13 +1,16 @@
|
||||
name: Build and Deploy Arctic Species Portal
|
||||
name: Build, Lint, and Deploy Arctic Species Portal
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main # Or your primary branch, e.g., master
|
||||
pull_request: # Also run on pull requests to main
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
build-and-deploy:
|
||||
runs-on: ubuntu-latest # This will use one of the labels your runner supports
|
||||
test-and-build: # Renamed job for clarity
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
@ -16,23 +19,52 @@ jobs:
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20' # Or your preferred/project's Node.js version
|
||||
node-version: '20'
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm install # If you use yarn, change this to 'yarn install'
|
||||
run: npm install
|
||||
|
||||
- name: Lint project
|
||||
run: npm run lint # Runs your ESLint command
|
||||
|
||||
- name: Build project
|
||||
run: npm run build # This command should be defined in your package.json scripts
|
||||
run: npm run build # Runs tsc && vite build
|
||||
# This will also catch TypeScript errors
|
||||
|
||||
- name: List output files
|
||||
- name: List output files # Optional: just to see build output in logs
|
||||
if: success() # Only run if build succeeds
|
||||
run: |
|
||||
echo "Build completed. Output files in dist/:"
|
||||
ls -R dist
|
||||
|
||||
- name: Deploy (Placeholder)
|
||||
deploy: # New job for deployment, depends on test-and-build
|
||||
needs: test-and-build # Ensures this job runs only if test-and-build succeeds
|
||||
if: gitea.event_name == 'push' && gitea.ref_name == 'main' # Corrected for Gitea
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
# We need to checkout and build again, or pass artifacts
|
||||
# For simplicity in this example, let's re-checkout and re-build
|
||||
# A more advanced setup would pass 'dist' as an artifact from the 'test-and-build' job
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm install
|
||||
|
||||
- name: Build project
|
||||
run: npm run build # Ensure the production assets are built for deployment
|
||||
|
||||
- name: Deploy to Production (Placeholder)
|
||||
run: |
|
||||
echo "Deployment step: Replace this with your actual deployment commands."
|
||||
echo "For example, copying files from 'dist/' to your server."
|
||||
echo "Files from 'dist/' are ready for deployment."
|
||||
# Example for copying to a server (requires SSH setup):
|
||||
# scp -r dist/* user@yourserver:/var/www/your-project-path/
|
||||
# Or using rsync:
|
||||
|
Reference in New Issue
Block a user