Compare commits
1 Commits
38494a4bec
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0c735f3097 |
73
.github/workflows/deploy.yml
vendored
73
.github/workflows/deploy.yml
vendored
@@ -23,6 +23,53 @@ env:
|
|||||||
REGISTRY_URL: ghcr.io/${{ github.repository_owner }}
|
REGISTRY_URL: ghcr.io/${{ github.repository_owner }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
deploy-config:
|
||||||
|
name: Check Deploy Configuration
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
staging_ready: ${{ steps.check.outputs.staging_ready }}
|
||||||
|
production_ready: ${{ steps.check.outputs.production_ready }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Check required deploy secrets
|
||||||
|
id: check
|
||||||
|
env:
|
||||||
|
TARGET_ENV: ${{ inputs.environment }}
|
||||||
|
STAGING_HOST: ${{ secrets.STAGING_HOST }}
|
||||||
|
STAGING_USER: ${{ secrets.STAGING_USER }}
|
||||||
|
STAGING_SSH_KEY: ${{ secrets.STAGING_SSH_KEY }}
|
||||||
|
STAGING_URL: ${{ secrets.STAGING_URL }}
|
||||||
|
STAGING_API_URL: ${{ secrets.STAGING_API_URL }}
|
||||||
|
PRODUCTION_HOST: ${{ secrets.PRODUCTION_HOST }}
|
||||||
|
PRODUCTION_USER: ${{ secrets.PRODUCTION_USER }}
|
||||||
|
PRODUCTION_SSH_KEY: ${{ secrets.PRODUCTION_SSH_KEY }}
|
||||||
|
PRODUCTION_URL: ${{ secrets.PRODUCTION_URL }}
|
||||||
|
PRODUCTION_API_URL: ${{ secrets.PRODUCTION_API_URL }}
|
||||||
|
run: |
|
||||||
|
STAGING_READY=false
|
||||||
|
PRODUCTION_READY=false
|
||||||
|
|
||||||
|
if [ -n "$STAGING_HOST" ] && [ -n "$STAGING_USER" ] && [ -n "$STAGING_SSH_KEY" ] && [ -n "$STAGING_URL" ] && [ -n "$STAGING_API_URL" ]; then
|
||||||
|
STAGING_READY=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$PRODUCTION_HOST" ] && [ -n "$PRODUCTION_USER" ] && [ -n "$PRODUCTION_SSH_KEY" ] && [ -n "$PRODUCTION_URL" ] && [ -n "$PRODUCTION_API_URL" ]; then
|
||||||
|
PRODUCTION_READY=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "staging_ready=$STAGING_READY" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "production_ready=$PRODUCTION_READY" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
if [ "${GITHUB_EVENT_NAME}" = "workflow_dispatch" ] && [ "$TARGET_ENV" = "staging" ] && [ "$STAGING_READY" != "true" ]; then
|
||||||
|
echo "Missing required staging deploy secrets; configure STAGING_HOST, STAGING_USER, STAGING_SSH_KEY, STAGING_URL, and STAGING_API_URL."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${GITHUB_EVENT_NAME}" = "workflow_dispatch" ] && [ "$TARGET_ENV" = "production" ] && [ "$PRODUCTION_READY" != "true" ]; then
|
||||||
|
echo "Missing required production deploy secrets; configure PRODUCTION_HOST, PRODUCTION_USER, PRODUCTION_SSH_KEY, PRODUCTION_URL, and PRODUCTION_API_URL."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
build-api:
|
build-api:
|
||||||
name: Build API Image
|
name: Build API Image
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -154,11 +201,14 @@ jobs:
|
|||||||
|
|
||||||
deploy-staging:
|
deploy-staging:
|
||||||
name: Deploy to Staging
|
name: Deploy to Staging
|
||||||
needs: [build-api, build-web, build-ai]
|
needs: [deploy-config, build-api, build-web, build-ai]
|
||||||
if: >-
|
if: >-
|
||||||
|
needs.deploy-config.outputs.staging_ready == 'true' &&
|
||||||
|
(
|
||||||
github.ref == 'refs/heads/develop' ||
|
github.ref == 'refs/heads/develop' ||
|
||||||
(github.event_name == 'push' && github.ref == 'refs/heads/master') ||
|
(github.event_name == 'push' && github.ref == 'refs/heads/master') ||
|
||||||
(github.event_name == 'workflow_dispatch' && inputs.environment == 'staging')
|
(github.event_name == 'workflow_dispatch' && inputs.environment == 'staging')
|
||||||
|
)
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
environment: staging
|
environment: staging
|
||||||
|
|
||||||
@@ -394,8 +444,11 @@ jobs:
|
|||||||
|
|
||||||
rollback-staging:
|
rollback-staging:
|
||||||
name: Rollback Staging
|
name: Rollback Staging
|
||||||
needs: [deploy-staging, smoke-test-staging]
|
needs: [deploy-config, deploy-staging, smoke-test-staging]
|
||||||
if: failure()
|
if: >-
|
||||||
|
always() &&
|
||||||
|
needs.deploy-config.outputs.staging_ready == 'true' &&
|
||||||
|
(needs.deploy-staging.result == 'failure' || needs.smoke-test-staging.result == 'failure')
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
environment: staging
|
environment: staging
|
||||||
|
|
||||||
@@ -462,8 +515,11 @@ jobs:
|
|||||||
|
|
||||||
deploy-production:
|
deploy-production:
|
||||||
name: Deploy to Production
|
name: Deploy to Production
|
||||||
needs: [build-api, build-web, build-ai]
|
needs: [deploy-config, build-api, build-web, build-ai]
|
||||||
if: inputs.environment == 'production'
|
if: >-
|
||||||
|
github.event_name == 'workflow_dispatch' &&
|
||||||
|
inputs.environment == 'production' &&
|
||||||
|
needs.deploy-config.outputs.production_ready == 'true'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
environment: production
|
environment: production
|
||||||
|
|
||||||
@@ -654,8 +710,11 @@ jobs:
|
|||||||
|
|
||||||
rollback-production:
|
rollback-production:
|
||||||
name: Rollback Production
|
name: Rollback Production
|
||||||
needs: [deploy-production, smoke-test-production]
|
needs: [deploy-config, deploy-production, smoke-test-production]
|
||||||
if: failure()
|
if: >-
|
||||||
|
always() &&
|
||||||
|
needs.deploy-config.outputs.production_ready == 'true' &&
|
||||||
|
(needs.deploy-production.result == 'failure' || needs.smoke-test-production.result == 'failure')
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
environment: production
|
environment: production
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user