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