Skip to content
This repository was archived by the owner on Apr 7, 2026. It is now read-only.

fix: replace BYOK with hosted billing, add Stripe+crypto to plans page #107

fix: replace BYOK with hosted billing, add Stripe+crypto to plans page

fix: replace BYOK with hosted billing, add Stripe+crypto to plans page #107

name: Deploy to Staging
on:
push:
branches: [main]
concurrency:
group: deploy-staging
cancel-in-progress: true
jobs:
deploy:
runs-on: [self-hosted, Linux, X64]
environment: staging
permissions:
packages: write
contents: read
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: |
ghcr.io/${{ github.repository }}:staging
ghcr.io/${{ github.repository }}:latest
ghcr.io/${{ github.repository }}:${{ github.sha }}
build-args: |
NEXT_PUBLIC_API_URL=${{ secrets.STAGING_API_URL }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Deploy to staging VPS
id: deploy
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets.STAGING_HOST }}
username: ${{ secrets.SSH_DEPLOY_USER }}
key: ${{ secrets.SSH_DEPLOY_KEY }}
script: |
if [ ! -f /opt/wopr-platform-ui/docker-compose.yml ]; then
echo "::error::docker-compose.yml not found at /opt/wopr-platform-ui/"
exit 1
fi
cd /opt/wopr-platform-ui
docker compose pull
docker compose up -d --remove-orphans
docker image prune -f
- name: Verify deployment health
id: health_check
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets.STAGING_HOST }}
username: ${{ secrets.SSH_DEPLOY_USER }}
key: ${{ secrets.SSH_DEPLOY_KEY }}
script: |
for i in $(seq 1 12); do
if curl -sf ${{ secrets.STAGING_HEALTH_CHECK_URL }} > /dev/null 2>&1; then
echo "Staging is healthy"
exit 0
fi
echo "Waiting for health check... ($i/12)"
sleep 5
done
echo "Health check timed out"
docker compose -f /opt/wopr-platform-ui/docker-compose.yml logs --tail=50
exit 1
- name: Rollback on failure
if: failure() && steps.health_check.outcome == 'failure'
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets.STAGING_HOST }}
username: ${{ secrets.SSH_DEPLOY_USER }}
key: ${{ secrets.SSH_DEPLOY_KEY }}
script: |
echo "Rolling back to previous version..."
cd /opt/wopr-platform-ui
docker compose down
docker compose pull ghcr.io/${{ github.repository }}:staging-previous || echo "No previous version found"
docker tag ghcr.io/${{ github.repository }}:staging-previous ghcr.io/${{ github.repository }}:staging || true
docker compose up -d --remove-orphans