Skip to content

Merge pull request #36 from GitAddRemote/feature/add-games-model #7

Merge pull request #36 from GitAddRemote/feature/add-games-model

Merge pull request #36 from GitAddRemote/feature/add-games-model #7

Workflow file for this run

name: Deploy
on:
workflow_dispatch:
inputs:
environment:
description: 'Environment to deploy to'
required: true
type: choice
options:
- staging
- production
skip_tests:
description: 'Skip tests (not recommended for production)'
required: false
type: boolean
default: false
push:
branches:
- main
paths:
- 'backend/**'
jobs:
test:
name: Run Tests
if: ${{ !inputs.skip_tests }}
runs-on: ubuntu-latest
services:
postgres:
image: postgres:15
env:
POSTGRES_USER: test
POSTGRES_PASSWORD: test
POSTGRES_DB: station_test
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 10
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Run unit tests
working-directory: backend
run: pnpm test
- name: Run E2E tests
working-directory: backend
env:
DATABASE_HOST: localhost
DATABASE_PORT: 5432
DATABASE_USER: test
DATABASE_PASSWORD: test
DATABASE_NAME: station_test
JWT_SECRET: test-secret-key
run: pnpm run test:e2e
build:
name: Build Application
runs-on: ubuntu-latest
needs: [test]
if: ${{ always() && (needs.test.result == 'success' || needs.test.result == 'skipped') }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 10
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build application
working-directory: backend
run: pnpm run build
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: backend-build
path: |
backend/dist
backend/package.json
retention-days: 7
deploy:
name: Deploy to ${{ inputs.environment || 'staging' }}
runs-on: ubuntu-latest
needs: [build]
environment: ${{ inputs.environment || 'staging' }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: backend-build
path: backend
- name: Deploy (Placeholder)
run: |
echo "🚀 Deploying to ${{ inputs.environment || 'staging' }} environment"
echo "ℹ️ Configure deployment steps based on your platform:"
echo ""
echo "Options:"
echo " - Docker: Build and push image, deploy to container service"
echo " - AWS: Deploy to Elastic Beanstalk, ECS, or Lambda"
echo " - Heroku: Use heroku/deploy-via-git action"
echo " - Azure: Use azure/webapps-deploy action"
echo " - GCP: Use google-github-actions/deploy-cloudrun"
echo ""
echo "📝 Update this workflow with your deployment strategy"
# Example Docker deployment (uncomment and configure)
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3
#
# - name: Login to Container Registry
# uses: docker/login-action@v3
# with:
# registry: ${{ secrets.REGISTRY_URL }}
# username: ${{ secrets.REGISTRY_USERNAME }}
# password: ${{ secrets.REGISTRY_PASSWORD }}
#
# - name: Build and push Docker image
# uses: docker/build-push-action@v5
# with:
# context: ./backend
# push: true
# tags: ${{ secrets.REGISTRY_URL }}/station-backend:${{ github.sha }}
# Example Heroku deployment (uncomment and configure)
# - name: Deploy to Heroku
# uses: akhileshns/heroku-deploy@v3.12.14
# with:
# heroku_api_key: ${{ secrets.HEROKU_API_KEY }}
# heroku_app_name: ${{ secrets.HEROKU_APP_NAME }}
# heroku_email: ${{ secrets.HEROKU_EMAIL }}
# appdir: backend
- name: Deployment summary
run: |
echo "✅ Deployment workflow completed"
echo "Environment: ${{ inputs.environment || 'staging' }}"
echo "Commit: ${{ github.sha }}"
echo "Actor: ${{ github.actor }}"