Build Catalog Images #290
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Build and Push Catalog Image to Quay.io | |
| name: Build Catalog Images | |
| on: | |
| schedule: | |
| - cron: '0 0 * * *' | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| env: | |
| REGISTRY: quay.io | |
| ORGANIZATION: redhat-best-practices-for-k8s | |
| IMAGE_NAME: qe-custom-catalog | |
| jobs: | |
| build-catalog-images: | |
| if: github.repository_owner == 'redhat-best-practices-for-k8s' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out code | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| with: | |
| ref: ${{ github.sha }} | |
| - name: Setup docker buildx | |
| uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0 | |
| # Binary: linux-amd64-opm - https://github.com/operator-framework/operator-registry/releases/ | |
| - name: Download latest opm binary from Github with retries | |
| uses: nick-fields/retry@v3 | |
| with: | |
| max_attempts: 5 | |
| timeout_minutes: 10 | |
| command: | | |
| # Get the latest release from the operator-registry repo | |
| curl -s https://api.github.com/repos/operator-framework/operator-registry/releases/latest \ | |
| | grep "browser_download_url.*linux-amd64-opm" \ | |
| | cut -d : -f 2,3 \ | |
| | tr -d \" \ | |
| | wget -qi - | |
| - name: Make opm binary executable | |
| run: chmod +x linux-amd64-opm | |
| - name: Run opm validate command with retries | |
| uses: nick-fields/retry@v3 | |
| with: | |
| max_attempts: 10 | |
| command: ./linux-amd64-opm validate custom-catalog | |
| timeout_minutes: 90 | |
| - name: Login to Quay.io | |
| uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0 | |
| if: ${{ github.ref == 'refs/heads/main' && github.repository_owner == 'redhat-best-practices-for-k8s' }} | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ secrets.QUAY_ROBOT_USERNAME }} | |
| password: ${{ secrets.QUAY_ROBOT_TOKEN }} | |
| - name: Force cleanup of docker | |
| run: sudo docker rm -f $(docker ps -aq) | |
| # Example: Pushes the image quay.io/redhat-best-practices-for-k8s/qe-custom-catalog:v4.14-latest | |
| # The idea being that we want to rebuild the images daily, but apply our custom catalog settings as well. | |
| - name: Build Catalog Image(s) with retries | |
| uses: nick-fields/retry@v3 | |
| with: | |
| max_attempts: 10 | |
| timeout_minutes: 90 | |
| command: | | |
| docker buildx build \ | |
| --platform linux/amd64,linux/arm64,linux/ppc64le,linux/s390x \ | |
| --file custom-catalog.Dockerfile \ | |
| --push \ | |
| --tag ${{ env.REGISTRY }}/${{ env.ORGANIZATION }}/${{ env.IMAGE_NAME }}:latest \ | |
| --cache-from type=registry,ref=${{ env.REGISTRY }}/${{ env.ORGANIZATION }}/${{ env.IMAGE_NAME }}:buildcache \ | |
| --cache-to type=registry,ref=${{ env.REGISTRY }}/${{ env.ORGANIZATION }}/${{ env.IMAGE_NAME }}:buildcache,mode=max \ | |
| . |