From 68b8707e3a3ed0d8b257b850a817996a72b8927a Mon Sep 17 00:00:00 2001 From: aradhyacp Date: Fri, 9 Jan 2026 20:23:12 +0530 Subject: [PATCH] Remove Docker CI workflow and add test deploy logic workflow to test --- .github/workflows/release.yml | 123 ------------------------------ .github/workflows/releasetest.yml | 43 +++++++++++ 2 files changed, 43 insertions(+), 123 deletions(-) delete mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/releasetest.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 1fb15c4..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,123 +0,0 @@ -name: Docker Image CI - -on: - push: - tags: - - '*' - -jobs: - docker-releases: - runs-on: ubuntu-latest - - steps: - - name: Get release version - run: echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV - - - name: Downcase username - run: echo "lower_actor=${GITHUB_ACTOR,,}" >> $GITHUB_ENV - - - name: Checkout - uses: actions/checkout@v4 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Login to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build and push Docker images - uses: docker/build-push-action@v6.9.0 - with: - context: ./ - push: true - tags: | - ghcr.io/${{ env.lower_actor }}/aperisolve:${{ env.RELEASE_VERSION }} - ghcr.io/${{ env.lower_actor }}/aperisolve:latest - - deploy: - runs-on: ubuntu-latest - needs: docker-releases - environment: prod - - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Check if tag is from prod branch - id: check - run: | - TAG_REF="${GITHUB_REF#refs/tags/}" - echo "Tag: $TAG_REF" - - # Get branches containing this commit - BRANCHES=$(git branch -r --contains HEAD) - echo "Branches containing this commit: $BRANCHES" - - if echo "$BRANCHES" | grep -q "origin/prod"; then - echo "is_prod=true" >> $GITHUB_OUTPUT - echo "✅ Tag is from prod branch - will deploy" - else - echo "is_prod=false" >> $GITHUB_OUTPUT - echo "❌ Tag is not from prod branch - skipping deployment" - fi - - # wait for 30 seconds - - name: Wait for image propagation - if: steps.check.outputs.is_prod == 'true' - run: | - echo "Waiting 30 seconds for image to propagate in registry..." - sleep 30 - - - name: Deploy to production server - if: steps.check.outputs.is_prod == 'true' - uses: appleboy/ssh-action@v1.0.3 - with: - host: ${{ secrets.PROD_SSH_HOST }} - username: ${{ secrets.PROD_SSH_USER }} - key: ${{ secrets.PROD_SSH_KEY }} - script: | - set -e - cd /root/AperiSolve - - # update code - git pull - - # create .env - cat < .env - MAX_CONTENT_LENGTH=${{ vars.MAX_CONTENT_LENGTH }} - MAX_PENDING_TIME=${{ vars.MAX_PENDING_TIME }} - MAX_STORE_TIME=${{ vars.MAX_STORE_TIME }} - CLEAR_AT_RESTART=${{ vars.CLEAR_AT_RESTART }} - SKIP_IHDR_FILL=${{ vars.SKIP_IHDR_FILL }} - - FLASK_DEBUG=${{ vars.FLASK_DEBUG }} - FLASK_ENV=${{ vars.FLASK_ENV }} - - RQ_DASHBOARD_REDIS_URL=${{ secrets.REDIS_URL }} - - POSTGRES_USER=${{ secrets.POSTGRES_USER }} - POSTGRES_PASSWORD=${{ secrets.POSTGRES_PASSWORD }} - POSTGRES_DB=${{ secrets.POSTGRES_DB }} - DB_URI=${{ secrets.DATABASE_URL }} - - SENTRY_DSN=${{ secrets.SENTRY_DSN }} - SENTRY_TRACES_SAMPLE_RATE=${{ secrets.SENTRY_TRACES_SAMPLE_RATE }} - SENTRY_PROFILES_SAMPLE_RATE=${{ secrets.SENTRY_PROFILES_SAMPLE_RATE }} - SENTRY_RELEASE=${{ secrets.SENTRY_RELEASE }} - SENTRY_ENVIRONMENT=${{ secrets.SENTRY_ENVIRONMENT }} - EOF - - # Pull images and deploy - docker compose pull - docker compose down - docker compose up -d - docker image prune -f diff --git a/.github/workflows/releasetest.yml b/.github/workflows/releasetest.yml new file mode 100644 index 0000000..71a3fa2 --- /dev/null +++ b/.github/workflows/releasetest.yml @@ -0,0 +1,43 @@ +name: Test Deploy Logic + +on: + push: + tags: + - '*' + +jobs: + test-deploy-check: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Check if tag is from prod branch + id: check + run: | + TAG_REF="${GITHUB_REF#refs/tags/}" + echo "Tag: $TAG_REF" + echo "GITHUB_SHA: $GITHUB_SHA" + + # Get branches containing this commit + BRANCHES=$(git branch -r --contains HEAD) + echo "Branches containing this commit: $BRANCHES" + + if echo "$BRANCHES" | grep -q "origin/prod"; then + echo "is_prod=true" >> $GITHUB_OUTPUT + echo "✅ Tag is from prod branch - will deploy" + else + echo "is_prod=false" >> $GITHUB_OUTPUT + echo "❌ Tag is not from prod branch - skipping deployment" + fi + + - name: Would Deploy + if: steps.check.outputs.is_prod == 'true' + run: echo "🚀 DEPLOYMENT WOULD HAPPEN HERE" + + - name: Would Skip + if: steps.check.outputs.is_prod != 'true' + run: echo "⏭️ DEPLOYMENT SKIPPED" \ No newline at end of file