From 0df17b1a28b5e06ca8abffe5ca098cb4debf1c8d Mon Sep 17 00:00:00 2001 From: Aditya Kumar Date: Wed, 1 Apr 2026 15:43:24 +0530 Subject: [PATCH 1/4] SCF-788: Added build & push workflow, on scalefield_v* pattern --- .github/workflows/build-and-push.yml | 163 +++++++++++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100644 .github/workflows/build-and-push.yml diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml new file mode 100644 index 000000000..b2970f719 --- /dev/null +++ b/.github/workflows/build-and-push.yml @@ -0,0 +1,163 @@ +name: Build and Push Docker Images to Harbor + +on: + push: + paths-ignore: + - '**.md' + - 'docs/**' + branches: + - 'scalefield_v*' + workflow_dispatch: + inputs: + image_tags: + description: 'Comma-separated list of tags' + required: true + type: string + run_e2e_tests: + description: 'Run E2E tests' + required: false + type: boolean + default: true + push_image: + description: 'Push images to Harbor' + required: false + type: boolean + default: true + +concurrency: + group: ${{ github.ref }} + cancel-in-progress: true + +jobs: + e2e-tests: + name: Run E2E Tests + if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.run_e2e_tests) + uses: ./.github/workflows/run_e2e.yaml + + build-and-push: + name: Build and Push Docker Images to Harbor + needs: [e2e-tests] + if: always() && (needs.e2e-tests.result == 'success' || needs.e2e-tests.result == 'skipped') + runs-on: ubuntu-latest-m + env: + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Determine tags + id: tags + run: | + if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then + echo "tags=${{ inputs.image_tags }}" >> $GITHUB_OUTPUT + else + FULL_SHA="${{ github.sha }}" + SHORT_SHA="${FULL_SHA:0:7}" + echo "tags=${FULL_SHA},${SHORT_SHA}" >> $GITHUB_OUTPUT + fi + + - name: Generate Harbor tags + id: harbor_tags + run: | + { + echo "operator_tags<> "$GITHUB_OUTPUT" + { + echo "logical_backup_tags<> "$GITHUB_OUTPUT" + + - name: Debug tags + run: | + echo "::group::Operator Image Tags" + echo "${{ steps.harbor_tags.outputs.operator_tags }}" + echo "::endgroup::" + echo "::group::Logical Backup Image Tags" + echo "${{ steps.harbor_tags.outputs.logical_backup_tags }}" + echo "::endgroup::" + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v4.0.0 + + - name: Log in to Harbor + uses: docker/login-action@v4 + with: + registry: ${{ vars.HARBOR_ORG }} + username: ${{ vars.HARBOR_USERNAME }} + password: ${{ secrets.HARBOR_PASSWORD }} + + - name: Build and push operator image + id: build_operator + uses: docker/build-push-action@v7 + continue-on-error: true + with: + context: . + file: docker/Dockerfile + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name != 'workflow_dispatch' || inputs.push_image }} + tags: ${{ steps.harbor_tags.outputs.operator_tags }} + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Notify Slack on operator build failure + if: steps.build_operator.outcome == 'failure' + uses: rtCamp/action-slack-notify@master + env: + SLACK_USERNAME: 'GitHub Actions' + SLACK_ICON_EMOJI: ':x:' + SLACK_COLOR: '#FF0000' + SLACK_TITLE: 'Postgres Operator image build failed' + SLACK_MESSAGE: 'Failed to build `postgres-operator` image with tags `${{ steps.tags.outputs.tags }}`. Please check the workflow logs for details.' + + - name: Build and push logical-backup image + id: build_logical_backup + uses: docker/build-push-action@v7 + continue-on-error: true + with: + context: logical-backup + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name != 'workflow_dispatch' || inputs.push_image }} + tags: ${{ steps.harbor_tags.outputs.logical_backup_tags }} + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Notify Slack on logical-backup build failure + if: steps.build_logical_backup.outcome == 'failure' + uses: rtCamp/action-slack-notify@master + env: + SLACK_USERNAME: 'GitHub Actions' + SLACK_ICON_EMOJI: ':x:' + SLACK_COLOR: '#FF0000' + SLACK_TITLE: 'Logical-backup image build failed' + SLACK_MESSAGE: 'Failed to build `postgres-operator/logical-backup` image with tags `${{ steps.tags.outputs.tags }}`. Please check the workflow logs for details.' + + - name: Check for build failures + if: steps.build_operator.outcome == 'failure' || steps.build_logical_backup.outcome == 'failure' + run: exit 1 + + - name: Notify Slack - Success + if: success() + uses: rtCamp/action-slack-notify@master + env: + SLACK_USERNAME: 'GitHub Actions' + SLACK_ICON_EMOJI: ':rocket:' + SLACK_COLOR: '#3278BD' + SLACK_TITLE: 'Images deployed to Harbor' + SLACK_MESSAGE: | + Postgres Operator images pushed with tags `${{ steps.tags.outputs.tags }}`. + Operator: ${{ vars.HARBOR_ORG }}/scalefield/postgres-operator + Logical-backup: ${{ vars.HARBOR_ORG }}/scalefield/postgres-operator/logical-backup + Harbor: https://containers.cybertec.at/harbor/projects/3/repositories/postgres-operator/artifacts-tab + From 78cf6f17a0c30c266c6e9b867cf6799a2a81d6bb Mon Sep 17 00:00:00 2001 From: Aditya Kumar Date: Wed, 1 Apr 2026 16:05:47 +0530 Subject: [PATCH 2/4] SCF-788: Added pull requests to test the workflow on the pr --- .github/workflows/build-and-push.yml | 15 +++++++++++---- .github/workflows/run_e2e.yaml | 3 ++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml index b2970f719..2ede76a6e 100644 --- a/.github/workflows/build-and-push.yml +++ b/.github/workflows/build-and-push.yml @@ -1,6 +1,12 @@ name: Build and Push Docker Images to Harbor on: + pull_request: + paths-ignore: + - '**.md' + - 'docs/**' + branches: + - 'scalefield_v*' push: paths-ignore: - '**.md' @@ -17,7 +23,7 @@ on: description: 'Run E2E tests' required: false type: boolean - default: true + default: false push_image: description: 'Push images to Harbor' required: false @@ -25,20 +31,21 @@ on: default: true concurrency: - group: ${{ github.ref }} + group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} cancel-in-progress: true jobs: e2e-tests: name: Run E2E Tests - if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.run_e2e_tests) + if: github.event_name == 'push' || github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && inputs.run_e2e_tests) uses: ./.github/workflows/run_e2e.yaml build-and-push: name: Build and Push Docker Images to Harbor needs: [e2e-tests] if: always() && (needs.e2e-tests.result == 'success' || needs.e2e-tests.result == 'skipped') - runs-on: ubuntu-latest-m + runs-on: ubuntu-latest + timeout-minutes: 60 env: SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} steps: diff --git a/.github/workflows/run_e2e.yaml b/.github/workflows/run_e2e.yaml index e7c04c0c5..d48eecfc6 100644 --- a/.github/workflows/run_e2e.yaml +++ b/.github/workflows/run_e2e.yaml @@ -1,6 +1,7 @@ name: operator-e2e-tests -on: +on: + workflow_call: pull_request: push: branches: From 50858ff013ddfd5ceb4ebae7ee10d0865c5016ae Mon Sep 17 00:00:00 2001 From: Aditya Kumar Date: Thu, 2 Apr 2026 15:48:47 +0530 Subject: [PATCH 3/4] SCF-788: Removed e2e tests from build and push workflow --- .github/workflows/build-and-push.yml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml index 2ede76a6e..ac47b5e91 100644 --- a/.github/workflows/build-and-push.yml +++ b/.github/workflows/build-and-push.yml @@ -19,11 +19,6 @@ on: description: 'Comma-separated list of tags' required: true type: string - run_e2e_tests: - description: 'Run E2E tests' - required: false - type: boolean - default: false push_image: description: 'Push images to Harbor' required: false @@ -35,15 +30,8 @@ concurrency: cancel-in-progress: true jobs: - e2e-tests: - name: Run E2E Tests - if: github.event_name == 'push' || github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && inputs.run_e2e_tests) - uses: ./.github/workflows/run_e2e.yaml - build-and-push: name: Build and Push Docker Images to Harbor - needs: [e2e-tests] - if: always() && (needs.e2e-tests.result == 'success' || needs.e2e-tests.result == 'skipped') runs-on: ubuntu-latest timeout-minutes: 60 env: From e64fe8136dfac46a8f96222083c34f16a361b6d6 Mon Sep 17 00:00:00 2001 From: Aditya Kumar Date: Thu, 2 Apr 2026 16:14:13 +0530 Subject: [PATCH 4/4] SCF-788: Removed slack notifications for now --- .github/workflows/build-and-push.yml | 43 ++-------------------------- 1 file changed, 2 insertions(+), 41 deletions(-) diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml index ac47b5e91..c66b7a66f 100644 --- a/.github/workflows/build-and-push.yml +++ b/.github/workflows/build-and-push.yml @@ -34,8 +34,6 @@ jobs: name: Build and Push Docker Images to Harbor runs-on: ubuntu-latest timeout-minutes: 60 - env: - SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} steps: - name: Checkout Repository uses: actions/checkout@v4 @@ -48,7 +46,8 @@ jobs: else FULL_SHA="${{ github.sha }}" SHORT_SHA="${FULL_SHA:0:7}" - echo "tags=${FULL_SHA},${SHORT_SHA}" >> $GITHUB_OUTPUT + BRANCH_NAME="${{ github.ref_name }}" + echo "tags=${BRANCH_NAME},${FULL_SHA},${SHORT_SHA}" >> $GITHUB_OUTPUT fi - name: Generate Harbor tags @@ -106,16 +105,6 @@ jobs: cache-from: type=gha cache-to: type=gha,mode=max - - name: Notify Slack on operator build failure - if: steps.build_operator.outcome == 'failure' - uses: rtCamp/action-slack-notify@master - env: - SLACK_USERNAME: 'GitHub Actions' - SLACK_ICON_EMOJI: ':x:' - SLACK_COLOR: '#FF0000' - SLACK_TITLE: 'Postgres Operator image build failed' - SLACK_MESSAGE: 'Failed to build `postgres-operator` image with tags `${{ steps.tags.outputs.tags }}`. Please check the workflow logs for details.' - - name: Build and push logical-backup image id: build_logical_backup uses: docker/build-push-action@v7 @@ -128,31 +117,3 @@ jobs: cache-from: type=gha cache-to: type=gha,mode=max - - name: Notify Slack on logical-backup build failure - if: steps.build_logical_backup.outcome == 'failure' - uses: rtCamp/action-slack-notify@master - env: - SLACK_USERNAME: 'GitHub Actions' - SLACK_ICON_EMOJI: ':x:' - SLACK_COLOR: '#FF0000' - SLACK_TITLE: 'Logical-backup image build failed' - SLACK_MESSAGE: 'Failed to build `postgres-operator/logical-backup` image with tags `${{ steps.tags.outputs.tags }}`. Please check the workflow logs for details.' - - - name: Check for build failures - if: steps.build_operator.outcome == 'failure' || steps.build_logical_backup.outcome == 'failure' - run: exit 1 - - - name: Notify Slack - Success - if: success() - uses: rtCamp/action-slack-notify@master - env: - SLACK_USERNAME: 'GitHub Actions' - SLACK_ICON_EMOJI: ':rocket:' - SLACK_COLOR: '#3278BD' - SLACK_TITLE: 'Images deployed to Harbor' - SLACK_MESSAGE: | - Postgres Operator images pushed with tags `${{ steps.tags.outputs.tags }}`. - Operator: ${{ vars.HARBOR_ORG }}/scalefield/postgres-operator - Logical-backup: ${{ vars.HARBOR_ORG }}/scalefield/postgres-operator/logical-backup - Harbor: https://containers.cybertec.at/harbor/projects/3/repositories/postgres-operator/artifacts-tab -