diff --git a/.github/workflows/build_push.yaml b/.github/workflows/build_push.yaml new file mode 100644 index 0000000..dd684de --- /dev/null +++ b/.github/workflows/build_push.yaml @@ -0,0 +1,135 @@ +name: On-demand build + +on: + workflow_dispatch: + inputs: + branch: + description: 'branch/tag to checkout' + required: true + default: 'main' + version: + description: 'image version' + required: true + go_version: + description: 'go version' + required: true + sdk_version: + description: 'operator-sdk version' + required: true + +env: + GO_VERSION: ${{ github.event.inputs.go_version }} + SDK_VERSION: ${{ github.event.inputs.sdk_version }} + VERSION: ${{ github.event.inputs.version }} + IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }} + DAEMON_REGISTRY: ghcr.io/${{ github.repository_owner }} + +jobs: + build-push-controller: + runs-on: ubuntu-latest + env: + IMAGE_NAME: ghcr.io/${{ github.repository }}-controller + steps: + - name: Checkout selected branch or tag + uses: actions/checkout@v4 + with: + ref: ${{ github.event.inputs.branch }} + + - uses: actions/setup-go@v2 + with: + go-version: ${{ env.GO_VERSION }} + - name: Tidy + run: | + go mod tidy + make generate fmt vet + - name: Set up Docker + uses: docker/setup-buildx-action@v1 + - name: Login to Docker + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ secrets.GH_USERNAME }} + password: ${{ secrets.GHCR_TOKEN }} + - name: Build and push controller + uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: | + ${{ env.IMAGE_NAME }}:v${{ env.VERSION }} + file: ./Dockerfile + build-push-bundle: + runs-on: ubuntu-latest + needs: build-push-controller + env: + BUNDLE_IMAGE_NAME: ghcr.io/${{ github.repository }}-bundle + CHANNELS: beta + steps: + - name: Checkout selected branch + uses: actions/checkout@v4 + with: + ref: ${{ github.event.inputs.branch }} + - uses: actions/setup-go@v2 + with: + go-version: ${{ env.GO_VERSION }} + - name: set ARCH and OD + run: | + echo "ARCH=$(case $(uname -m) in x86_64) echo -n amd64 ;; aarch64) echo -n arm64 ;; *) echo -n $(uname -m) ;; esac)" >> $GITHUB_ENV + echo "OS=$(uname | awk '{print tolower($0)}')" >> $GITHUB_ENV + echo "OPERATOR_SDK_DL_URL=https://github.com/operator-framework/operator-sdk/releases/download/v${{ env.SDK_VERSION }}" >> $GITHUB_ENV + - name: download operator-sdk + run: curl -LO ${{ env.OPERATOR_SDK_DL_URL }}/operator-sdk_${{ env.OS }}_${{ env.ARCH }} + - name: move operator-sdk to binary path + run: chmod +x operator-sdk_${{ env.OS }}_${{ env.ARCH }} && sudo mv operator-sdk_${{ env.OS }}_${{ env.ARCH }} /usr/local/bin/operator-sdk + - name: Tidy + run: | + go mod tidy + - name: Make bundle + run: make bundle + - name: Set up Docker + uses: docker/setup-buildx-action@v1 + - name: Login to Docker + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ secrets.GH_USERNAME }} + password: ${{ secrets.GHCR_TOKEN }} + - name: Build and push bundle + uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: | + ${{ env.BUNDLE_IMAGE_NAME }}:v${{ env.VERSION }} + file: ./bundle.Dockerfile + build-push-daemon: + runs-on: ubuntu-latest + env: + IMAGE_NAME: ghcr.io/${{ github.repository }}-daemon + steps: + - name: Checkout selected branch + uses: actions/checkout@v4 + with: + ref: ${{ github.event.inputs.branch }} + - uses: actions/setup-go@v2 + with: + go-version: ${{ env.GO_VERSION }} + - name: Set up Docker + uses: docker/setup-buildx-action@v1 + - name: Update CNI + run: make update-cni-local + working-directory: daemon + - name: Login to Docker + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ secrets.GH_USERNAME }} + password: ${{ secrets.GHCR_TOKEN }} + - name: Build and push daemon + uses: docker/build-push-action@v2 + with: + context: daemon + push: true + tags: | + ${{ env.IMAGE_NAME }}:v${{ env.VERSION }} + file: ./daemon/dockerfiles/Dockerfile \ No newline at end of file