From faec571ec890971aeb2abdafe08b8dc16553a158 Mon Sep 17 00:00:00 2001 From: Daniel-Robotics Date: Thu, 15 May 2025 12:03:36 +1000 Subject: [PATCH] Update logic --- .github/workflows/ci.yaml | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2c2f403..7be0004 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -2,13 +2,13 @@ name: CI Pipeline on: push: - branches: [ '**' ] # На все пуши (включая main) + branches: ['**'] pull_request: - branches: [ main ] # На PR в main + branches: [main] permissions: contents: read - packages: write # нужно для Docker push в GHCR + packages: write jobs: test: @@ -32,20 +32,25 @@ jobs: docker: name: Build and push Docker image + needs: test runs-on: ubuntu-latest - needs: test # Выполняется только если тесты прошли - if: github.event_name == 'pull_request' + + # Условие: либо push в main, либо PR в main + if: | + github.event_name == 'push' && github.ref == 'refs/heads/main' || + github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'main' + steps: - uses: actions/checkout@v4 - - name: Log in to GitHub Container Registry + - name: Log in to GHCR uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Set lowercase owner + - name: Owner in lowercase id: vars run: | OWNER_LC=$(echo "${GITHUB_REPOSITORY%/*}" | tr '[:upper:]' '[:lower:]')