From 5598065e9759d874f3c61a3b9f96d0cf7ee7eb8d Mon Sep 17 00:00:00 2001 From: shtlrs Date: Sun, 21 May 2023 09:58:11 +0100 Subject: build docker image in all PRs This will always trigger the build-deploy workflow The image will only be pushed & deployed if we're in main. --- .github/workflows/build-deploy.yml | 7 ++++++- .github/workflows/main.yml | 1 - 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-deploy.yml b/.github/workflows/build-deploy.yml index 2582a4113..8f984d9b9 100644 --- a/.github/workflows/build-deploy.yml +++ b/.github/workflows/build-deploy.yml @@ -1,5 +1,9 @@ name: Build & Deploy +env: + # Used to determine whether we should push & deploy the docker image. + IS_MAIN_REF: ${{ github.ref == github.event.repository.default_branch }} + on: workflow_call: inputs: @@ -44,7 +48,7 @@ jobs: with: context: . file: ./Dockerfile - push: true + push: $IS_MAIN_REF cache-from: type=registry,ref=ghcr.io/python-discord/bot:latest cache-to: type=inline tags: | @@ -57,6 +61,7 @@ jobs: name: Deploy needs: build runs-on: ubuntu-latest + if: $IS_MAIN_REF environment: production steps: - name: Checkout Kubernetes repository diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0f972b16f..a512f289d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -31,7 +31,6 @@ jobs: build-deploy: - if: github.ref == 'refs/heads/main' uses: ./.github/workflows/build-deploy.yml needs: - lint-test -- cgit v1.2.3