diff --git a/.github/workflows/build-image.yaml b/.github/workflows/build-image.yaml new file mode 100644 index 0000000..be6f8ee --- /dev/null +++ b/.github/workflows/build-image.yaml @@ -0,0 +1,88 @@ +--- +name: Build container images + +# yamllint disable-line rule:truthy +on: + pull_request: + branches: + - "*" + push: + branches: + - main + - 'release-*' + +jobs: + build: + name: build_${{ matrix.image.name }} + if: github.repository == 'ramendr/ceph-volsync-plugin' + runs-on: ubuntu-latest + strategy: + matrix: + image: + - name: bundle + dockerfile: bundle.Dockerfile + image_name: quay.io/ramendr/ceph-volsync-plugin-operator-bundle + needs_go: true + needs_docker_buildx: false + - name: operator + dockerfile: build/Containerfile.manager + image_name: quay.io/ramendr/ceph-volsync-plugin-operator + needs_go: false + needs_docker_buildx: true + - name: mover + dockerfile: build/Containerfile.mover + image_name: quay.io/ramendr/ceph-volsync-plugin-mover + needs_go: false + needs_docker_buildx: true + steps: + - name: Check out the repo + uses: actions/checkout@v5 + + - name: Setup Golang + if: matrix.image.needs_go + uses: actions/setup-go@v6 + with: + go-version-file: go.mod + + - name: Set up QEMU + if: matrix.image.needs_docker_buildx + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + if: matrix.image.needs_docker_buildx + uses: docker/setup-buildx-action@v3 + + - name: Generate image tag + id: tag + run: | + if [[ "${{ github.ref_name }}" == release-* ]]; then + version=$(echo "${{ github.ref_name }}" | sed 's/release-//') + tag="v${version}-latest" + echo "Generated tag: $tag" + echo "tag=$tag" >> $GITHUB_OUTPUT + else + tag="latest" + echo "Generated tag: $tag" + echo "tag=$tag" >> $GITHUB_OUTPUT + fi + + - name: Generate the bundle contents + if: matrix.image.name == 'bundle' + run: make bundle + + - name: Login to quay.io + if: github.event_name == 'push' + uses: docker/login-action@v3 + with: + registry: quay.io + username: ${{ secrets.QUAY_USERNAME }} + password: ${{ secrets.QUAY_PASSWORD }} + + - name: Build and push container image + uses: docker/build-push-action@v6 + with: + context: . + file: ${{ matrix.image.dockerfile }} + platforms: ${{ matrix.image.needs_docker_buildx && vars.BUILD_PLATFORMS || '' }} + push: ${{ github.event_name == 'push' }} + tags: ${{ matrix.image.image_name }}:${{ steps.tag.outputs.tag }}