128 lines
3.6 KiB
YAML
128 lines
3.6 KiB
YAML
name: Deploy
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
workflow_dispatch:
|
|
inputs:
|
|
environment:
|
|
description: 'Deployment environment'
|
|
required: true
|
|
default: 'production'
|
|
type: choice
|
|
options:
|
|
- staging
|
|
- production
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
deploy:
|
|
name: Deploy to ${{ github.event.inputs.environment || 'production' }}
|
|
runs-on: ubuntu-latest
|
|
environment:
|
|
name: ${{ github.event.inputs.environment || 'production' }}
|
|
|
|
# Only deploy after successful linting, testing, and building
|
|
needs: [lint, test, build]
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
cache: 'yarn'
|
|
|
|
- name: Install dependencies
|
|
run: yarn install --frozen-lockfile
|
|
|
|
- name: Build project
|
|
run: yarn build
|
|
env:
|
|
NODE_ENV: production
|
|
|
|
# Example deployment step - replace with your actual deployment strategy
|
|
# Options:
|
|
# - Docker container registry
|
|
# - Cloud provider (AWS, GCP, Azure)
|
|
# - Traditional hosting (Vercel, Netlify, Cloudflare Pages)
|
|
# - SSH deployment to VPS
|
|
|
|
# Example: Docker image build and push
|
|
# - name: Set up Docker Buildx
|
|
# uses: docker/setup-buildx-action@v3
|
|
|
|
# - name: Log in 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: .
|
|
# push: true
|
|
# tags: ${{ secrets.REGISTRY_URL }}/glyphdiff:latest
|
|
# cache-from: type=gha
|
|
# cache-to: type=gha,mode=max
|
|
|
|
# Example: SSH deployment to server
|
|
# - name: Deploy to server via SSH
|
|
# uses: appleboy/ssh-action@v1.0.3
|
|
# with:
|
|
# host: ${{ secrets.DEPLOY_HOST }}
|
|
# username: ${{ secrets.DEPLOY_USER }}
|
|
# key: ${{ secrets.DEPLOY_SSH_KEY }}
|
|
# script: |
|
|
# cd /path/to/app
|
|
# git pull origin main
|
|
# yarn install --frozen-lockfile
|
|
# yarn build
|
|
# pm2 restart glyphdiff
|
|
|
|
# Example: Deploy to Vercel
|
|
# - name: Deploy to Vercel
|
|
# uses: amondnet/vercel-action@v25
|
|
# with:
|
|
# vercel-token: ${{ secrets.VERCEL_TOKEN }}
|
|
# vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
|
|
# vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }}
|
|
# vercel-args: '--prod'
|
|
|
|
- name: Deployment placeholder
|
|
run: |
|
|
echo "Deployment step not configured yet."
|
|
echo "Uncomment and modify one of the deployment examples above."
|
|
echo "Configure the necessary secrets in your Gitea instance:"
|
|
echo " - REGISTRY_URL, REGISTRY_USERNAME, REGISTRY_PASSWORD"
|
|
echo " - DEPLOY_HOST, DEPLOY_USER, DEPLOY_SSH_KEY"
|
|
echo " - VERCEL_TOKEN, VERCEL_ORG_ID, VERCEL_PROJECT_ID"
|
|
|
|
- name: Post-deployment health check
|
|
run: |
|
|
echo "Add health check here after deployment"
|
|
# curl -f https://your-app.com || exit 1
|
|
|
|
lint:
|
|
name: Lint Check
|
|
uses: ./.gitea/workflows/lint.yml
|
|
secrets: inherit
|
|
|
|
test:
|
|
name: Test Suite
|
|
uses: ./.gitea/workflows/test.yml
|
|
secrets: inherit
|
|
|
|
build:
|
|
name: Build Verification
|
|
uses: ./.gitea/workflows/build.yml
|
|
secrets: inherit
|