feat: Initial commit - Train tracking system
Some checks failed
Auto Tag on Merge to Main / auto-tag (push) Successful in 27s
CI - Lint and Build / lint-backend (push) Failing after 30s
CI - Lint and Build / lint-frontend (push) Failing after 2s
CI - Lint and Build / build-frontend (push) Has been skipped
CI - Lint and Build / docker-build-test (push) Has been skipped
Some checks failed
Auto Tag on Merge to Main / auto-tag (push) Successful in 27s
CI - Lint and Build / lint-backend (push) Failing after 30s
CI - Lint and Build / lint-frontend (push) Failing after 2s
CI - Lint and Build / build-frontend (push) Has been skipped
CI - Lint and Build / docker-build-test (push) Has been skipped
Complete real-time train tracking system for Spanish railways (Renfe/Cercanías): - Backend API (Node.js/Express) with GTFS-RT polling workers - Frontend dashboard (React/Vite) with Leaflet maps - Real-time updates via Socket.io WebSocket - PostgreSQL/PostGIS database with Flyway migrations - Redis caching layer - Docker Compose configuration for development and production - Gitea CI/CD workflows (lint, auto-tag, release) - Production deployment with nginx + Let's Encrypt SSL 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
98
.gitea/workflows/auto-tag.yml
Normal file
98
.gitea/workflows/auto-tag.yml
Normal file
@@ -0,0 +1,98 @@
|
||||
name: Auto Tag on Merge to Main
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths-ignore:
|
||||
- '*.md'
|
||||
- 'docs/**'
|
||||
- '.gitignore'
|
||||
|
||||
jobs:
|
||||
auto-tag:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0 # Fetch all history for proper versioning
|
||||
|
||||
- name: Get latest tag
|
||||
id: get_tag
|
||||
run: |
|
||||
# Get the latest tag, default to v0.0.0 if none exists
|
||||
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
|
||||
echo "latest_tag=$LATEST_TAG" >> $GITHUB_OUTPUT
|
||||
echo "Latest tag: $LATEST_TAG"
|
||||
|
||||
- name: Determine version bump
|
||||
id: bump
|
||||
run: |
|
||||
# Get commit messages since last tag
|
||||
LATEST_TAG="${{ steps.get_tag.outputs.latest_tag }}"
|
||||
|
||||
# If no real tag exists (v0.0.0), get all commits
|
||||
if [ "$LATEST_TAG" == "v0.0.0" ]; then
|
||||
COMMITS=$(git log --pretty=format:"%s")
|
||||
else
|
||||
COMMITS=$(git log $LATEST_TAG..HEAD --pretty=format:"%s")
|
||||
fi
|
||||
|
||||
# Determine version bump type based on conventional commits
|
||||
BUMP_TYPE="patch"
|
||||
|
||||
if echo "$COMMITS" | grep -qiE "^(feat|feature)(\(.+\))?!:|^BREAKING CHANGE:"; then
|
||||
BUMP_TYPE="major"
|
||||
elif echo "$COMMITS" | grep -qiE "^(feat|feature)(\(.+\))?:"; then
|
||||
BUMP_TYPE="minor"
|
||||
elif echo "$COMMITS" | grep -qiE "^(fix|bugfix|perf|refactor)(\(.+\))?:"; then
|
||||
BUMP_TYPE="patch"
|
||||
fi
|
||||
|
||||
echo "bump_type=$BUMP_TYPE" >> $GITHUB_OUTPUT
|
||||
echo "Version bump type: $BUMP_TYPE"
|
||||
|
||||
- name: Calculate new version
|
||||
id: new_version
|
||||
run: |
|
||||
LATEST_TAG="${{ steps.get_tag.outputs.latest_tag }}"
|
||||
BUMP_TYPE="${{ steps.bump.outputs.bump_type }}"
|
||||
|
||||
# Remove 'v' prefix and split version
|
||||
VERSION=${LATEST_TAG#v}
|
||||
IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"
|
||||
|
||||
# Bump version based on type
|
||||
if [ "$BUMP_TYPE" == "major" ]; then
|
||||
MAJOR=$((MAJOR + 1))
|
||||
MINOR=0
|
||||
PATCH=0
|
||||
elif [ "$BUMP_TYPE" == "minor" ]; then
|
||||
MINOR=$((MINOR + 1))
|
||||
PATCH=0
|
||||
else
|
||||
PATCH=$((PATCH + 1))
|
||||
fi
|
||||
|
||||
NEW_VERSION="v$MAJOR.$MINOR.$PATCH"
|
||||
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
|
||||
echo "New version: $NEW_VERSION"
|
||||
|
||||
- name: Create and push tag
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
NEW_VERSION="${{ steps.new_version.outputs.new_version }}"
|
||||
|
||||
# Configure git
|
||||
git config user.name "Gitea Actions"
|
||||
git config user.email "actions@gitea.local"
|
||||
|
||||
# Create annotated tag
|
||||
git tag -a "$NEW_VERSION" -m "Release $NEW_VERSION"
|
||||
|
||||
# Push tag
|
||||
git push origin "$NEW_VERSION"
|
||||
|
||||
echo "Created and pushed tag: $NEW_VERSION"
|
||||
116
.gitea/workflows/ci.yml
Normal file
116
.gitea/workflows/ci.yml
Normal file
@@ -0,0 +1,116 @@
|
||||
name: CI - Lint and Build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- develop
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
lint-backend:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: 'npm'
|
||||
cache-dependency-path: backend/package-lock.json
|
||||
|
||||
- name: Install backend dependencies
|
||||
run: |
|
||||
cd backend
|
||||
npm ci
|
||||
|
||||
- name: Run ESLint (backend)
|
||||
run: |
|
||||
cd backend
|
||||
npm run lint || true
|
||||
|
||||
- name: Check formatting with Prettier
|
||||
run: |
|
||||
cd backend
|
||||
npx prettier --check "src/**/*.js" || true
|
||||
|
||||
lint-frontend:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: 'npm'
|
||||
cache-dependency-path: frontend/package-lock.json
|
||||
|
||||
- name: Install frontend dependencies
|
||||
run: |
|
||||
cd frontend
|
||||
npm ci
|
||||
|
||||
- name: Run ESLint (frontend)
|
||||
run: |
|
||||
cd frontend
|
||||
npm run lint || true
|
||||
|
||||
build-frontend:
|
||||
runs-on: ubuntu-latest
|
||||
needs: lint-frontend
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: 'npm'
|
||||
cache-dependency-path: frontend/package-lock.json
|
||||
|
||||
- name: Install frontend dependencies
|
||||
run: |
|
||||
cd frontend
|
||||
npm ci
|
||||
|
||||
- name: Build frontend
|
||||
run: |
|
||||
cd frontend
|
||||
npm run build
|
||||
env:
|
||||
VITE_API_URL: http://localhost/api
|
||||
VITE_WS_URL: http://localhost
|
||||
|
||||
docker-build-test:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [lint-backend, lint-frontend]
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Build backend image (test)
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: ./backend
|
||||
push: false
|
||||
tags: trenes-backend:test
|
||||
|
||||
- name: Build frontend image (test)
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: ./frontend
|
||||
push: false
|
||||
build-args: |
|
||||
VITE_API_URL=http://localhost/api
|
||||
VITE_WS_URL=http://localhost
|
||||
tags: trenes-frontend:test
|
||||
76
.gitea/workflows/release.yml
Normal file
76
.gitea/workflows/release.yml
Normal file
@@ -0,0 +1,76 @@
|
||||
name: Release - Build and Publish Docker Images
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*.*.*'
|
||||
|
||||
jobs:
|
||||
build-and-publish:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Extract version from tag
|
||||
id: version
|
||||
run: |
|
||||
VERSION=${GITHUB_REF#refs/tags/v}
|
||||
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||
echo "Building version: $VERSION"
|
||||
|
||||
- name: Get current date
|
||||
id: date
|
||||
run: echo "date=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to Gitea Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ secrets.REGISTRY_URL }}
|
||||
username: ${{ secrets.REGISTRY_USERNAME }}
|
||||
password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
|
||||
- name: Build and push backend image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: ./backend
|
||||
push: true
|
||||
build-args: |
|
||||
APP_VERSION=${{ steps.version.outputs.version }}
|
||||
BUILD_DATE=${{ steps.date.outputs.date }}
|
||||
GIT_COMMIT=${{ github.sha }}
|
||||
tags: |
|
||||
${{ secrets.REGISTRY_URL }}/trenes/backend:${{ steps.version.outputs.version }}
|
||||
${{ secrets.REGISTRY_URL }}/trenes/backend:latest
|
||||
provenance: false
|
||||
sbom: false
|
||||
|
||||
- name: Build and push frontend image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: ./frontend
|
||||
push: true
|
||||
build-args: |
|
||||
VITE_API_URL=${{ secrets.PROD_API_URL }}
|
||||
VITE_WS_URL=${{ secrets.PROD_WS_URL }}
|
||||
APP_VERSION=${{ steps.version.outputs.version }}
|
||||
BUILD_DATE=${{ steps.date.outputs.date }}
|
||||
GIT_COMMIT=${{ github.sha }}
|
||||
tags: |
|
||||
${{ secrets.REGISTRY_URL }}/trenes/frontend:${{ steps.version.outputs.version }}
|
||||
${{ secrets.REGISTRY_URL }}/trenes/frontend:latest
|
||||
provenance: false
|
||||
sbom: false
|
||||
|
||||
- name: Summary
|
||||
run: |
|
||||
echo "### Docker Images Published 🐳" >> $GITHUB_STEP_SUMMARY
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "**Version:** ${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "**Images:**" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- \`${{ secrets.REGISTRY_URL }}/trenes/backend:${{ steps.version.outputs.version }}\`" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- \`${{ secrets.REGISTRY_URL }}/trenes/frontend:${{ steps.version.outputs.version }}\`" >> $GITHUB_STEP_SUMMARY
|
||||
Reference in New Issue
Block a user