From b0e78c9e2af1acbf1d5126af44e4c2ffb3b42859 Mon Sep 17 00:00:00 2001 From: Safwan Date: Thu, 6 Nov 2025 20:53:01 +0500 Subject: [PATCH 1/6] shared gateway workflow --- .github/workflows/gateway_pull_request.yaml | 141 ++++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 .github/workflows/gateway_pull_request.yaml diff --git a/.github/workflows/gateway_pull_request.yaml b/.github/workflows/gateway_pull_request.yaml new file mode 100644 index 0000000..929fd3d --- /dev/null +++ b/.github/workflows/gateway_pull_request.yaml @@ -0,0 +1,141 @@ +name: Operator PR Request + +on: + workflow_call: + inputs: + ENABLE_LINTING: + description: Run golangci-lint + default: true + required: false + type: boolean + + ENABLE_UNIT_TESTS: + description: Run golang tests + default: true + required: false + type: boolean + + RELEASE_BRANCH: + description: Release branch to push changes + required: false + type: string + default: main + + GO_VERSION: + description: Go version to use + required: false + default: "1.25.0" + type: string + + ENABLE_STAKATER_AB_GIT_AUTH: + description: "Configure git to use stakater-ab private repos" + required: false + default: false + type: boolean + + ENABLE_CHART_PUSH: + description: "Enable pushing helm charts to chart repo" + required: false + default: false + type: boolean + + GIT_USER: + description: "Git user to push changes" + required: false + default: stakater-github-root + type: string + + secrets: + SLACK_WEBHOOK_URL: + description: "Secret to send success/failure message to slack" + required: true + + CONTAINER_REGISTRY_URL: + description: "Registry URL to publish image" + required: true + + CONTAINER_REGISTRY_USERNAME: + description: "Registry username to login" + required: true + + CONTAINER_REGISTRY_PASSWORD: + description: "Registry password to login" + required: true + + STAKATER_AB_REPOS: + description: "GitHub token with access to stakater-ab repos" + required: false + +jobs: + make-gateway-pull-request: + name: Gateway Pull Request + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v5 + with: + fetch-depth: 2 + + - name: Setup Go + uses: actions/setup-go@v6 + with: + go-version: ${{ inputs.GO_VERSION }} + + - name: Show Go Version + run: go version + + - name: Configure private repo + if: ${{ inputs.ENABLE_STAKATER_AB_GIT_AUTH }} + run: | + git config --global url."https://${{ secrets.STAKATER_AB_REPOS }}:x-oauth-basic@github.com/stakater-ab".insteadOf "https://github.com/stakater-ab" + + - name: Verify code + id: verify + uses: stakater/.github/.github/actions/operator/verify@main + with: + ENABLE_LINTING: ${{ inputs.ENABLE_LINTING }} + ENABLE_UNIT_TESTS: ${{ inputs.ENABLE_UNIT_TESTS }} + + - name: Setup Version Tag + id: tag + uses: stakater/.github/.github/actions/operator/tag@main + with: + RELEASE_BRANCH: ${{ inputs.RELEASE_BRANCH }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Setup Docker + id: docker + uses: stakater/.github/.github/actions/operator/docker@main + env: + CONTAINER_REGISTRY_URL: ${{ secrets.CONTAINER_REGISTRY_URL }} + CONTAINER_REGISTRY_USERNAME: ${{ secrets.CONTAINER_REGISTRY_USERNAME }} + CONTAINER_REGISTRY_PASSWORD: ${{ secrets.CONTAINER_REGISTRY_PASSWORD }} + + - name: Build & Push + run: | + make build docker-build docker-push + + - name: Publish Helm Chart + if: ${{ inputs.ENABLE_CHART_PUSH }} + uses: stakater/.github/.github/actions/operator/chart-push@main + with: + VERSION: ${{ steps.tag.outputs.TAG }} + TAG: ${{ steps.tag.outputs.PR_TAG }} + CHART_REPOSITORY: "ghcr.io/stakater/charts" + env: + ADMIN_TOKEN: ${{ secrets.ADMIN_TOKEN }} + GHCR_USERNAME: ${{ secrets.CONTAINER_REGISTRY_USERNAME }} + GHCR_TOKEN: ${{ secrets.CONTAINER_REGISTRY_PASSWORD }} + + - name: Notify + uses: stakater/.github/.github/actions/operator/notify@main + with: + VERSION: ${{ steps.tag.outputs.TAG }} + TAG: ${{ steps.tag.outputs.PR_TAG }} + IMAGE_REPOSITORY: ${{ steps.docker.outputs.IMAGE_REPOSITORY }} + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + ADMIN_TOKEN: ${{ secrets.ADMIN_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From f02f032f257d043c796062818f8a3552f56004a5 Mon Sep 17 00:00:00 2001 From: Safwan Date: Thu, 6 Nov 2025 21:27:01 +0500 Subject: [PATCH 2/6] fix env --- .github/workflows/gateway_pull_request.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/gateway_pull_request.yaml b/.github/workflows/gateway_pull_request.yaml index 929fd3d..2f6267e 100644 --- a/.github/workflows/gateway_pull_request.yaml +++ b/.github/workflows/gateway_pull_request.yaml @@ -116,6 +116,10 @@ jobs: - name: Build & Push run: | make build docker-build docker-push + env: + VERSION: ${{ steps.tag.outputs.TAG }} + GIT_TAG: ${{ steps.tag.outputs.PR_TAG }} + IMAGE_REPOSITORY: ${{ steps.docker.outputs.IMAGE_REPOSITORY }} - name: Publish Helm Chart if: ${{ inputs.ENABLE_CHART_PUSH }} From 03503f7545443c192e2944a1f3f990aec7fdfe50 Mon Sep 17 00:00:00 2001 From: Safwan Date: Mon, 10 Nov 2025 12:25:01 +0500 Subject: [PATCH 3/6] use same actions from operators --- .github/actions/operator/build/action.yaml | 17 +++++++++++++++-- .github/workflows/gateway_pull_request.yaml | 12 ++++++++---- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/.github/actions/operator/build/action.yaml b/.github/actions/operator/build/action.yaml index 1fd6733..ee3ce1d 100644 --- a/.github/actions/operator/build/action.yaml +++ b/.github/actions/operator/build/action.yaml @@ -28,6 +28,12 @@ inputs: description: OPM CLI version to use default: "v1.50.0" required: false + + IS_OPERATOR: + description: "Is Operator build" + required: false + default: true + runs: using: "composite" steps: @@ -37,14 +43,20 @@ runs: source: "github" opm: ${{ inputs.OPM_VERSION }} + - name: Generate Manifests + if: ${{ inputs.IS_OPERATOR }} + run: make manifests + shell: bash + - name: Build and push controller - run: make manifests build docker-build docker-push + run: make build docker-build docker-push shell: bash env: VERSION: ${{ inputs.VERSION }} GIT_TAG: ${{ inputs.TAG }} - name: Build and push bundle + if: ${{ inputs.IS_OPERATOR }} run: make bundle bundle-build bundle-push shell: bash env: @@ -52,6 +64,7 @@ runs: GIT_TAG: ${{ inputs.TAG }} - name: Render catalog index + if: ${{ inputs.IS_OPERATOR }} run: make catalog-render shell: bash env: @@ -61,7 +74,7 @@ runs: # Build and push only if index.yaml have been generated - name: Build and push catalog id: catalog_build - if: ${{ hashFiles(format('{0}/**/index.yaml', inputs.CATALOG_DIR_PATH)) != '' }} + if: ${{ inputs.IS_OPERATOR && hashFiles(format('{0}/**/index.yaml', inputs.CATALOG_DIR_PATH)) != '' }} env: VERSION: ${{ inputs.VERSION }} GIT_TAG: ${{ inputs.TAG }} diff --git a/.github/workflows/gateway_pull_request.yaml b/.github/workflows/gateway_pull_request.yaml index 2f6267e..8839f76 100644 --- a/.github/workflows/gateway_pull_request.yaml +++ b/.github/workflows/gateway_pull_request.yaml @@ -114,12 +114,16 @@ jobs: CONTAINER_REGISTRY_PASSWORD: ${{ secrets.CONTAINER_REGISTRY_PASSWORD }} - name: Build & Push - run: | - make build docker-build docker-push - env: + uses: stakater/.github/.github/actions/operator/build@shared_gateway_workflow + with: VERSION: ${{ steps.tag.outputs.TAG }} - GIT_TAG: ${{ steps.tag.outputs.PR_TAG }} + TAG: ${{ steps.tag.outputs.PR_TAG }} IMAGE_REPOSITORY: ${{ steps.docker.outputs.IMAGE_REPOSITORY }} + IS_OPERATOR: false + env: + ADMIN_TOKEN: ${{ secrets.ADMIN_TOKEN }} + GIT_TOKEN: ${{ secrets.STAKATER_AB_REPOS }} + GIT_USER: ${{ inputs.GIT_USER }} - name: Publish Helm Chart if: ${{ inputs.ENABLE_CHART_PUSH }} From d6b61b41d464b6971833b246d79acb154517476b Mon Sep 17 00:00:00 2001 From: Safwan Date: Mon, 10 Nov 2025 12:27:33 +0500 Subject: [PATCH 4/6] fixed name --- .github/workflows/gateway_pull_request.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gateway_pull_request.yaml b/.github/workflows/gateway_pull_request.yaml index 8839f76..d0a41ce 100644 --- a/.github/workflows/gateway_pull_request.yaml +++ b/.github/workflows/gateway_pull_request.yaml @@ -114,7 +114,7 @@ jobs: CONTAINER_REGISTRY_PASSWORD: ${{ secrets.CONTAINER_REGISTRY_PASSWORD }} - name: Build & Push - uses: stakater/.github/.github/actions/operator/build@shared_gateway_workflow + uses: stakater/.github/.github/actions/operator/build@shared-gateway-workflow with: VERSION: ${{ steps.tag.outputs.TAG }} TAG: ${{ steps.tag.outputs.PR_TAG }} From 94ac23de7b5943e2f5cc7920c3f50edc1ab75cb6 Mon Sep 17 00:00:00 2001 From: Safwan Date: Mon, 10 Nov 2025 12:35:56 +0500 Subject: [PATCH 5/6] fixed flag type --- .github/actions/operator/build/action.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/actions/operator/build/action.yaml b/.github/actions/operator/build/action.yaml index ee3ce1d..81ec2cd 100644 --- a/.github/actions/operator/build/action.yaml +++ b/.github/actions/operator/build/action.yaml @@ -32,6 +32,7 @@ inputs: IS_OPERATOR: description: "Is Operator build" required: false + type: boolean default: true runs: From 0f5539d4138c17c545ef96e508e6f695b6d14914 Mon Sep 17 00:00:00 2001 From: Safwan Date: Mon, 10 Nov 2025 12:46:14 +0500 Subject: [PATCH 6/6] fix checks in build action --- .github/actions/operator/build/action.yaml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/actions/operator/build/action.yaml b/.github/actions/operator/build/action.yaml index 81ec2cd..4a0054f 100644 --- a/.github/actions/operator/build/action.yaml +++ b/.github/actions/operator/build/action.yaml @@ -39,13 +39,14 @@ runs: using: "composite" steps: - name: Install CLI tools + if: ${{ inputs.IS_OPERATOR == 'true' }} uses: redhat-actions/openshift-tools-installer@v1 with: source: "github" opm: ${{ inputs.OPM_VERSION }} - name: Generate Manifests - if: ${{ inputs.IS_OPERATOR }} + if: ${{ inputs.IS_OPERATOR == 'true' }} run: make manifests shell: bash @@ -57,7 +58,7 @@ runs: GIT_TAG: ${{ inputs.TAG }} - name: Build and push bundle - if: ${{ inputs.IS_OPERATOR }} + if: ${{ inputs.IS_OPERATOR == 'true' }} run: make bundle bundle-build bundle-push shell: bash env: @@ -65,7 +66,7 @@ runs: GIT_TAG: ${{ inputs.TAG }} - name: Render catalog index - if: ${{ inputs.IS_OPERATOR }} + if: ${{ inputs.IS_OPERATOR == 'true' }} run: make catalog-render shell: bash env: @@ -75,7 +76,7 @@ runs: # Build and push only if index.yaml have been generated - name: Build and push catalog id: catalog_build - if: ${{ inputs.IS_OPERATOR && hashFiles(format('{0}/**/index.yaml', inputs.CATALOG_DIR_PATH)) != '' }} + if: ${{ inputs.IS_OPERATOR == 'true' && hashFiles(format('{0}/**/index.yaml', inputs.CATALOG_DIR_PATH)) != '' }} env: VERSION: ${{ inputs.VERSION }} GIT_TAG: ${{ inputs.TAG }}