diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml new file mode 100644 index 000000000..c66b7a66f --- /dev/null +++ b/.github/workflows/build-and-push.yml @@ -0,0 +1,119 @@ +name: Build and Push Docker Images to Harbor + +on: + pull_request: + paths-ignore: + - '**.md' + - 'docs/**' + branches: + - 'scalefield_v*' + push: + paths-ignore: + - '**.md' + - 'docs/**' + branches: + - 'scalefield_v*' + workflow_dispatch: + inputs: + image_tags: + description: 'Comma-separated list of tags' + required: true + type: string + push_image: + description: 'Push images to Harbor' + required: false + type: boolean + default: true + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} + cancel-in-progress: true + +jobs: + build-and-push: + name: Build and Push Docker Images to Harbor + runs-on: ubuntu-latest + timeout-minutes: 60 + 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}" + BRANCH_NAME="${{ github.ref_name }}" + echo "tags=${BRANCH_NAME},${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: 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 + 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: