diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index c31a7e1..94d1433 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -1,36 +1,21 @@ name: Deploy Company Site -# Deploy pipeline runs only on direct pushes to master (never on pull requests). +# Runs after Unit Tests completes on master. Direct pushes only (not PRs). on: - push: + workflow_run: + workflows: [Unit Tests] + types: [completed] branches: [master] jobs: - test: - runs-on: self-hosted - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Install uv - run: | - curl -LsSf https://astral.sh/uv/install.sh | sh - echo "$HOME/.local/bin" >> "$GITHUB_PATH" - - - name: Run unit tests - env: - DJANGO_ENV: dev - DJANGO_SECRET_KEY: test-secret-key - run: | - cd company_site - uv run python manage.py test - docker: + if: gitea.event.workflow_run.conclusion == 'success' && gitea.event.workflow_run.event == 'push' runs-on: self-hosted - needs: test steps: - name: Checkout uses: actions/checkout@v4 + with: + ref: ${{ gitea.event.workflow_run.head_sha }} - name: Build Docker image run: docker compose build @@ -46,15 +31,22 @@ jobs: docker compose down deploy: + if: gitea.event.workflow_run.conclusion == 'success' && gitea.event.workflow_run.event == 'push' runs-on: self-hosted - needs: [test, docker] + needs: docker env: SERVER_INFRA_ROOT: /home/westfarn/Documents/repos/server-infra ANSIBLE_PRIVATE_KEY_FILE: /var/lib/act_runner/.ssh/id_ed25519 steps: + - name: Show job user + run: | + whoami + id + echo "HOME=$HOME" + - name: Deploy company_site prod run: | "${SERVER_INFRA_ROOT}/scripts/deploy.sh" \ --app company_site \ --env prod \ - --ref "${{ gitea.sha }}" + --ref "${{ gitea.event.workflow_run.head_sha }}"