From 2fe549482d2d6a5ab79b757731994d94cc4a5218 Mon Sep 17 00:00:00 2001 From: Jonathan Miller Date: Sat, 30 May 2026 10:58:52 -0500 Subject: [PATCH] fix(ci): auto-deploy to production on merge to main Add push trigger on main branch to deploy-mokogitea.yml so merges to main automatically deploy to production. When triggered by push, the version is derived from git describe and environment defaults to production. Manual workflow_dispatch still works for explicit version deployments and dev environment targeting. Co-Authored-By: Claude Opus 4.6 (1M context) --- .mokogitea/workflows/deploy-mokogitea.yml | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/.mokogitea/workflows/deploy-mokogitea.yml b/.mokogitea/workflows/deploy-mokogitea.yml index 84e4583eee..72087ce74d 100644 --- a/.mokogitea/workflows/deploy-mokogitea.yml +++ b/.mokogitea/workflows/deploy-mokogitea.yml @@ -5,6 +5,9 @@ name: Deploy MokoGitea on: + push: + branches: + - main workflow_dispatch: inputs: version: @@ -36,11 +39,23 @@ jobs: deploy: runs-on: ubuntu-latest steps: + - name: Checkout source (for version detection) + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Determine settings id: config run: | - VERSION="${{ github.event.inputs.version }}" - ENV="${{ github.event.inputs.environment }}" + # On push to main, auto-deploy to production with git-derived version. + # On workflow_dispatch, use the provided inputs. + if [ "${{ github.event_name }}" = "push" ]; then + VERSION=$(git describe --tags --always 2>/dev/null || echo "dev-$(git rev-parse --short HEAD)") + ENV="production" + else + VERSION="${{ github.event.inputs.version }}" + ENV="${{ github.event.inputs.environment }}" + fi if [ "$ENV" = "production" ]; then echo "compose_dir=/opt/gitea" >> $GITHUB_OUTPUT @@ -146,7 +161,7 @@ jobs: GITEA_TOKEN: ${{ secrets.MOKOGITEA_TOKEN }} TAG: ${{ steps.config.outputs.tag }} INSTANCE_URL: ${{ steps.config.outputs.instance_url }} - DEPLOY_ENV: ${{ github.event.inputs.environment }} + DEPLOY_ENV: ${{ github.event.inputs.environment || 'production' }} run: | # Only update updates.xml for production stable releases if [ "$DEPLOY_ENV" != "production" ]; then -- 2.52.0