diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fdf043991..75e189f42 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,6 +40,7 @@ jobs: run: pnpm build --filter='!@buster-app/web' env: NODE_ENV: production + SKIP_ENV_CHECK: true TURBO_CACHE_DIR: .turbo TURBO_TELEMETRY_DISABLED: 1 @@ -102,6 +103,7 @@ jobs: run: pnpm build --filter='!@buster-app/web' env: NODE_ENV: production + SKIP_ENV_CHECK: true TURBO_CACHE_DIR: .turbo TURBO_TELEMETRY_DISABLED: 1 diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index e8ce0c706..0ae7d85d3 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -5,18 +5,32 @@ on: workflows: ["Build and Push Server Docker Image"] types: - completed + workflow_dispatch: + inputs: + environment: + description: 'Environment to deploy to' + required: true + type: choice + options: + - staging + - main + default: staging + image_tag: + description: 'Docker image tag to deploy (e.g., staging-abc123 or main-def456)' + required: true + type: string jobs: deploy: - if: ${{ github.event.workflow_run.conclusion == 'success' && (github.event.workflow_run.head_branch == 'main' || github.event.workflow_run.head_branch == 'staging') }} + if: ${{ (github.event_name == 'workflow_dispatch') || (github.event.workflow_run.conclusion == 'success' && (github.event.workflow_run.head_branch == 'main' || github.event.workflow_run.head_branch == 'staging')) }} runs-on: blacksmith-2vcpu-ubuntu-2404 - environment: ${{ github.event.workflow_run.head_branch == 'main' && 'production' || github.event.workflow_run.head_branch == 'staging' && 'staging' || '' }} + environment: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.environment || github.event.workflow_run.head_branch }} steps: - name: Checkout code uses: actions/checkout@v4 with: - ref: ${{ github.event.workflow_run.head_branch }} + ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.environment || github.event.workflow_run.head_branch }} - name: Get commit SHA id: commit @@ -30,24 +44,23 @@ jobs: - name: Update Porter app with new image id: deploy run: | - BRANCH="${{ github.event.workflow_run.head_branch }}" - SHA="${{ steps.commit.outputs.sha_short }}" + # Determine deployment parameters based on trigger type + if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then + BRANCH="${{ github.event.inputs.environment }}" + TAG="${{ github.event.inputs.image_tag }}" + echo "🔧 Manual deployment triggered" + else + BRANCH="${{ github.event.workflow_run.head_branch }}" + SHA="${{ steps.commit.outputs.sha_short }}" + TAG="${BRANCH}-${SHA}" + echo "🔄 Automatic deployment triggered" + fi echo "🚀 Deploying to ${BRANCH} environment..." - if [[ "$BRANCH" == "main" ]]; then - echo "📦 Using image tag: ${SHA}" - else - echo "📦 Using image tag: staging-${SHA}" - fi + echo "📦 Using image tag: ${TAG}" - # Update the Porter app with the new image tag - if [[ "$BRANCH" == "main" ]]; then - porter app update-tag ${{ vars.PORTER_APP_NAME }} --tag "${SHA}" - echo "deployment_env=production" >> $GITHUB_OUTPUT - else - porter app update-tag ${{ vars.PORTER_APP_NAME }} --tag "staging-${SHA}" - echo "deployment_env=staging" >> $GITHUB_OUTPUT - fi + porter app update-tag ${{ vars.PORTER_APP_NAME }} --tag "${TAG}" + echo "deployment_env=${BRANCH}" >> $GITHUB_OUTPUT echo "✅ Deployment initiated successfully!" env: @@ -67,25 +80,43 @@ jobs: - name: Create deployment summary if: success() run: | - BRANCH="${{ github.event.workflow_run.head_branch }}" - SHA="${{ steps.commit.outputs.sha_short }}" + if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then + BRANCH="${{ github.event.inputs.environment }}" + TAG="${{ github.event.inputs.image_tag }}" + TRIGGER_TYPE="Manual" + else + BRANCH="${{ github.event.workflow_run.head_branch }}" + SHA="${{ steps.commit.outputs.sha_short }}" + TAG="${BRANCH}-${SHA}" + TRIGGER_TYPE="Automatic" + fi ENV="${{ steps.deploy.outputs.deployment_env }}" echo "## 🎉 Deployment Successful!" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY echo "- **Environment:** \`${ENV}\`" >> $GITHUB_STEP_SUMMARY echo "- **Branch:** \`${BRANCH}\`" >> $GITHUB_STEP_SUMMARY - echo "- **Commit:** \`${SHA}\`" >> $GITHUB_STEP_SUMMARY + echo "- **Image Tag:** \`${TAG}\`" >> $GITHUB_STEP_SUMMARY echo "- **Full SHA:** \`${{ steps.commit.outputs.sha_full }}\`" >> $GITHUB_STEP_SUMMARY + echo "- **Trigger Type:** ${TRIGGER_TYPE}" >> $GITHUB_STEP_SUMMARY echo "- **Triggered by:** ${{ github.actor }}" >> $GITHUB_STEP_SUMMARY echo "- **Time:** $(date -u +'%Y-%m-%d %H:%M:%S UTC')" >> $GITHUB_STEP_SUMMARY - name: Handle deployment failure if: failure() run: | + if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then + ENV="${{ github.event.inputs.environment }}" + TAG="${{ github.event.inputs.image_tag }}" + else + ENV="${{ github.event.workflow_run.head_branch }}" + TAG="(automatic)" + fi + echo "## ❌ Deployment Failed!" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY - echo "- **Environment:** ${{ github.event.workflow_run.head_branch }}" >> $GITHUB_STEP_SUMMARY + echo "- **Environment:** ${ENV}" >> $GITHUB_STEP_SUMMARY + echo "- **Image Tag:** ${TAG}" >> $GITHUB_STEP_SUMMARY echo "- **Error:** Check the logs above for details" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY echo "### Next Steps:" >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/porter_app_staging-hono-server_3155.yml b/.github/workflows/porter_app_staging-hono-server_3155.yml deleted file mode 100644 index 641863fa1..000000000 --- a/.github/workflows/porter_app_staging-hono-server_3155.yml +++ /dev/null @@ -1,29 +0,0 @@ -"on": - push: - branches: - - staging -name: Deploy to staging-hono-server -jobs: - porter-deploy: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Set Github tag - id: vars - run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT - - name: Setup porter - uses: porter-dev/setup-porter@v0.1.0 - - name: Deploy stack - timeout-minutes: 30 - run: exec porter apply - env: - PORTER_APP_NAME: staging-hono-server - PORTER_CLUSTER: "3155" - PORTER_DEPLOYMENT_TARGET_ID: 7f44813f-4b0c-4be7-add0-94ebb61256bf - PORTER_HOST: https://dashboard.porter.run - PORTER_PR_NUMBER: ${{ github.event.number }} - PORTER_PROJECT: "9309" - PORTER_REPO_NAME: ${{ github.event.repository.name }} - PORTER_TAG: ${{ steps.vars.outputs.sha_short }} - PORTER_TOKEN: ${{ secrets.PORTER_APP_9309_3155 }}