Fix: untrack accidentally-committed worktree submodule + gitignore .c… #22
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build & Deploy | |
| on: | |
| push: | |
| branches: [main] | |
| env: | |
| IMAGE: ghcr.io/leanderantony/ai_job_application_agent/api | |
| VPS_APP_DIR: /home/ubuntu/AI_Job_Application_Agent | |
| jobs: | |
| build-and-push: | |
| name: Build Docker image to GHCR | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| - name: Log in to GHCR | |
| uses: docker/login-action@v4 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ github.token }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Build and push | |
| uses: docker/build-push-action@v7 | |
| with: | |
| context: . | |
| push: true | |
| tags: ${{ env.IMAGE }}:latest,${{ env.IMAGE }}:${{ github.sha }} | |
| cache-from: type=registry,ref=${{ env.IMAGE }}:cache | |
| cache-to: type=registry,ref=${{ env.IMAGE }}:cache,mode=max | |
| deploy: | |
| name: Deploy to VPS | |
| runs-on: ubuntu-latest | |
| needs: build-and-push | |
| permissions: | |
| contents: read | |
| packages: read | |
| env: | |
| GITHUB_ACTOR: ${{ github.actor }} | |
| GITHUB_TOKEN: ${{ github.token }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| - name: Prepare VPS directory | |
| uses: appleboy/ssh-action@v1 | |
| with: | |
| host: ${{ secrets.VPS_HOST }} | |
| username: ${{ secrets.VPS_USER }} | |
| key: ${{ secrets.VPS_SSH_KEY }} | |
| port: ${{ secrets.VPS_PORT }} | |
| script: | | |
| mkdir -p "${{ env.VPS_APP_DIR }}/backend/vps" | |
| - name: Copy deployment files | |
| uses: appleboy/scp-action@v0.1.7 | |
| with: | |
| host: ${{ secrets.VPS_HOST }} | |
| username: ${{ secrets.VPS_USER }} | |
| key: ${{ secrets.VPS_SSH_KEY }} | |
| port: ${{ secrets.VPS_PORT }} | |
| source: backend/vps/docker-compose.yml,backend/vps/docker-compose.override.yml | |
| target: ${{ env.VPS_APP_DIR }}/backend/vps | |
| strip_components: 2 | |
| - name: Deploy via SSH | |
| uses: appleboy/ssh-action@v1 | |
| env: | |
| IMAGE: ${{ env.IMAGE }} | |
| GITHUB_ACTOR: ${{ env.GITHUB_ACTOR }} | |
| GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }} | |
| with: | |
| host: ${{ secrets.VPS_HOST }} | |
| username: ${{ secrets.VPS_USER }} | |
| key: ${{ secrets.VPS_SSH_KEY }} | |
| port: ${{ secrets.VPS_PORT }} | |
| envs: IMAGE,GITHUB_TOKEN,GITHUB_ACTOR | |
| script: | | |
| echo "$GITHUB_TOKEN" | docker login ghcr.io -u "$GITHUB_ACTOR" --password-stdin | |
| docker pull "$IMAGE:latest" | |
| cd "${{ env.VPS_APP_DIR }}/backend/vps" | |
| docker compose -p ai_job_application_agent up -d --no-deps --no-build --force-recreate api | |
| docker logout ghcr.io | |
| - name: Health check | |
| uses: appleboy/ssh-action@v1 | |
| with: | |
| host: ${{ secrets.VPS_HOST }} | |
| username: ${{ secrets.VPS_USER }} | |
| key: ${{ secrets.VPS_SSH_KEY }} | |
| port: ${{ secrets.VPS_PORT }} | |
| script: | | |
| echo "Waiting for AI Job Application Agent API to be healthy..." | |
| for i in $(seq 1 12); do | |
| STATUS=$(docker inspect --format='{{.State.Health.Status}}' ai-job-application-agent-api 2>/dev/null) | |
| echo "Attempt $i: $STATUS" | |
| if [ "$STATUS" = "healthy" ]; then | |
| echo "Container is healthy" | |
| exit 0 | |
| fi | |
| sleep 5 | |
| done | |
| echo "Container did not become healthy in time" | |
| docker logs ai-job-application-agent-api --tail 30 | |
| exit 1 |