From 8afbe01e9ec428fe71d1d97e9009e75efe481842 Mon Sep 17 00:00:00 2001 From: Saumya Date: Fri, 29 Aug 2025 14:49:09 +0530 Subject: [PATCH] fix github workflow branch update issue --- .github/workflows/docker-build.yml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 6697dd49..eb943348 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -6,6 +6,8 @@ on: - main - PRODUCTION workflow_dispatch: + repository_dispatch: + types: [production-updated] permissions: contents: read @@ -16,11 +18,21 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.event_name == 'repository_dispatch' && 'PRODUCTION' || github.ref }} - name: Get tag name shell: bash run: | - if [[ "${GITHUB_REF#refs/heads/}" == "main" ]]; then + echo "Event name: ${{ github.event_name }}" + echo "Current ref: ${{ github.ref }}" + echo "Branch: ${GITHUB_REF#refs/heads/}" + + if [[ "${{ github.event_name }}" == "repository_dispatch" ]]; then + echo "Triggered by repository dispatch - setting prod environment" + echo "branch=prod" >> $GITHUB_OUTPUT + echo "environment=prod" >> $GITHUB_OUTPUT + elif [[ "${GITHUB_REF#refs/heads/}" == "main" ]]; then echo "branch=latest" >> $GITHUB_OUTPUT echo "environment=staging" >> $GITHUB_OUTPUT elif [[ "${GITHUB_REF#refs/heads/}" == "PRODUCTION" ]]; then @@ -62,7 +74,8 @@ jobs: key: ${{ secrets.STAGING_KEY }} script: | cd /home/suna/backend - git pull + git fetch origin main + git reset --hard origin/main docker compose build docker compose up -d