From b64dc66d4900cd60deff1f023b2b656acb908364 Mon Sep 17 00:00:00 2001 From: Jeff Emmett Date: Wed, 1 Apr 2026 00:51:50 -0700 Subject: [PATCH] CI: temp deploy-test job to debug container+registry access --- .gitea/workflows/ci.yml | 58 +++++++++-------------------------------- 1 file changed, 12 insertions(+), 46 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 9887338..d371ca4 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -39,8 +39,7 @@ jobs: env: NODE_OPTIONS: "--max-old-space-size=4096" - deploy: - if: ${{ github.ref == 'refs/heads/main' && github.event_name == 'push' }} + deploy-test: needs: [test-and-build] runs-on: ubuntu-latest container: @@ -48,52 +47,19 @@ jobs: volumes: - /var/run/docker.sock:/var/run/docker.sock steps: - - name: Setup tools - run: apk add --no-cache git openssh-client curl - - - name: Checkout - run: git clone --depth 1 --branch ${{ github.ref_name }} http://token:${{ github.token }}@server:3000/${{ github.repository }}.git . - - - name: Set image tag + - name: Debug context run: | - SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-8) - echo "IMAGE_TAG=${SHORT_SHA}" >> $GITHUB_ENV - echo "Building image tag: ${SHORT_SHA}" + echo "github.ref=${{ github.ref }}" + echo "github.ref_name=${{ github.ref_name }}" + echo "github.event_name=${{ github.event_name }}" + echo "github.repository=${{ github.repository }}" + echo "REGISTRY=${{ env.REGISTRY }}" + echo "IMAGE=${{ env.IMAGE }}" - - name: Build image - run: docker build -t ${{ env.IMAGE }}:${{ env.IMAGE_TAG }} -t ${{ env.IMAGE }}:latest . + - name: Test docker access + run: docker info --format '{{.ServerVersion}}' - - name: Push to registry + - name: Test registry login run: | echo "${{ secrets.REGISTRY_TOKEN }}" | docker login ${{ env.REGISTRY }} -u ${{ secrets.REGISTRY_USER }} --password-stdin - docker push ${{ env.IMAGE }}:${{ env.IMAGE_TAG }} - docker push ${{ env.IMAGE }}:latest - - - name: Deploy to server - run: | - mkdir -p ~/.ssh - echo "${{ secrets.DEPLOY_SSH_KEY }}" | base64 -d > ~/.ssh/deploy_key - chmod 600 ~/.ssh/deploy_key - ssh -o StrictHostKeyChecking=no -i ~/.ssh/deploy_key root@${{ secrets.DEPLOY_HOST }} " - cd /opt/websites/canvas-website-staging - cat .last-deployed-tag 2>/dev/null > .rollback-tag || true - echo '${{ env.IMAGE_TAG }}' > .last-deployed-tag - docker pull ${{ env.IMAGE }}:${{ env.IMAGE_TAG }} - IMAGE_TAG=${{ env.IMAGE_TAG }} docker compose up -d --no-build - " - - - name: Smoke test - run: | - sleep 10 - HTTP_CODE=$(curl -sS -o /dev/null -w "%{http_code}" --max-time 15 https://jeffemmett.com/ 2>/dev/null || echo "000") - if [ "$HTTP_CODE" != "200" ]; then - echo "Smoke test failed (HTTP $HTTP_CODE) — rolling back" - ROLLBACK_TAG=$(ssh -o StrictHostKeyChecking=no -i ~/.ssh/deploy_key root@${{ secrets.DEPLOY_HOST }} "cat /opt/websites/canvas-website-staging/.rollback-tag 2>/dev/null") - if [ -n "$ROLLBACK_TAG" ]; then - ssh -o StrictHostKeyChecking=no -i ~/.ssh/deploy_key root@${{ secrets.DEPLOY_HOST }} \ - "cd /opt/websites/canvas-website-staging && IMAGE_TAG=$ROLLBACK_TAG docker compose up -d --no-build" - echo "Rolled back to $ROLLBACK_TAG" - fi - exit 1 - fi - echo "Smoke test passed (HTTP $HTTP_CODE)" + echo "Registry login successful"