-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #125 from stakater/operator-PR
Generic Operator Pull Request workflow
- Loading branch information
Showing
2 changed files
with
120 additions
and
16 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,12 +9,24 @@ on: | |
required: false | ||
type: string | ||
|
||
RUN_GOLANG_CI_LINT: | ||
description: Run golangci-lint | ||
default: true | ||
required: false | ||
type: boolean | ||
|
||
GOLANG_CI_LINT_VERSION: | ||
description: golang-ci-lint version to use | ||
default: "v1.50.1" | ||
default: "v1.53.3" | ||
required: false | ||
type: string | ||
|
||
RUN_GOLANG_TESTS: | ||
description: Run golang tests | ||
default: true | ||
required: false | ||
type: boolean | ||
|
||
HELM_VERSION: | ||
description: Helm version to use | ||
default: "v3.8.2" | ||
|
@@ -28,24 +40,38 @@ on: | |
|
||
HELM_CHARTS_PATH: | ||
description: Helm charts path | ||
required: true | ||
required: false | ||
type: string | ||
|
||
BOT_USERNAME: | ||
description: Bot username to create release | ||
required: true | ||
default: "stakater-github-root" | ||
required: false | ||
type: string | ||
|
||
BOT_EMAIL: | ||
description: Bot email to create release | ||
required: true | ||
default: "[email protected]" | ||
required: false | ||
type: string | ||
|
||
RELEASE_BRANCH: | ||
description: Release branch to push changes | ||
required: true | ||
type: string | ||
|
||
BUILD_CUSTOM_CATALOG: | ||
description: Build custom catalog | ||
default: false | ||
required: false | ||
type: boolean | ||
|
||
OPERATOR_SDK_VERSION: | ||
description: Operator SDK version to use | ||
default: "v1.32.0" | ||
required: false | ||
type: string | ||
|
||
secrets: | ||
ADMIN_TOKEN: | ||
description: "Secret to pull latest tag" | ||
|
@@ -69,15 +95,15 @@ on: | |
|
||
HELM_REGISTRY_URL: | ||
description: "Helm registry to publish helm chart" | ||
required: true | ||
required: false | ||
|
||
HELM_REGISTRY_USERNAME: | ||
description: "Username to login to helm registry" | ||
required: true | ||
required: false | ||
|
||
HELM_REGISTRY_PASSWORD: | ||
description: "Password to login to helm registry" | ||
required: true | ||
required: false | ||
|
||
jobs: | ||
push-operator-setup: | ||
|
@@ -98,6 +124,7 @@ jobs: | |
fi | ||
- name: Check if helm registry secrets are set | ||
if: ${{ inputs.HELM_CHARTS_PATH != '' }} | ||
run: | | ||
if [ "${{ secrets.HELM_REGISTRY_URL }}" == "" ] || [ "${{ secrets.HELM_REGISTRY_USERNAME }}" == "" ] || [ "${{ secrets.HELM_REGISTRY_PASSWORD }}" == "" ]; then | ||
echo "Required secrets 'HELM_REGISTRY_URL' or 'HELM_REGISTRY_USERNAME' or 'HELM_REGISTRY_PASSWORD' are not set!" | ||
|
@@ -118,6 +145,7 @@ jobs: | |
go-version: ${{ inputs.GOLANG_VERSION }} | ||
|
||
- name: Lint | ||
if: ${{ inputs.RUN_GOLANG_CI_LINT }} | ||
uses: golangci/golangci-lint-action@v6 | ||
with: | ||
version: ${{ inputs.GOLANG_CI_LINT_VERSION }} | ||
|
@@ -126,6 +154,7 @@ jobs: | |
|
||
# Run Tests | ||
- name: Test | ||
if: ${{ inputs.RUN_GOLANG_TESTS }} | ||
run: make test | ||
|
||
- name: Generate Tag | ||
|
@@ -167,6 +196,7 @@ jobs: | |
|
||
# Set up helm binary | ||
- name: Set up Helm | ||
if: ${{ inputs.HELM_CHARTS_PATH != '' }} | ||
uses: azure/setup-helm@v4 | ||
with: | ||
version: ${{ inputs.HELM_VERSION }} | ||
|
@@ -184,7 +214,7 @@ jobs: | |
driver-opts: | | ||
image=moby/buildkit:v0.9.3 | ||
buildkitd-flags: --debug | ||
|
||
- name: Login to Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
|
@@ -194,6 +224,7 @@ jobs: | |
|
||
- name: Build and push | ||
uses: docker/build-push-action@v6 | ||
id: build_and_push | ||
with: | ||
context: . | ||
file: ${{ inputs.DOCKERFILE_PATH }} | ||
|
@@ -206,17 +237,35 @@ jobs: | |
org.opencontainers.image.source=${{ github.event.repository.clone_url }} | ||
org.opencontainers.image.revision=${{ github.sha }} | ||
# Build custom catalog | ||
- name: Install CLI tools from OpenShift Mirror | ||
if: ${{ inputs.BUILD_CUSTOM_CATALOG }} | ||
uses: redhat-actions/openshift-tools-installer@v1 | ||
with: | ||
source: "github" | ||
operator-sdk: ${{ inputs.OPERATOR_SDK_VERSION }} | ||
|
||
- name: Build and Push Bundle and Catalog | ||
if: ${{ inputs.BUILD_CUSTOM_CATALOG }} | ||
run: make custom-bundle bundle-build bundle-push catalog-build catalog-push | ||
env: | ||
IMAGE_DIGEST: ${{ steps.build_and_push.outputs.digest }} | ||
VERSION: ${{ needs.push-operator-setup.outputs.new_tag_without_v }} | ||
|
||
# Update chart tag to the latest semver tag | ||
- name: Update Chart Version | ||
if: ${{ inputs.HELM_CHARTS_PATH != '' }} | ||
env: | ||
VERSION: ${{ needs.push-operator-setup.outputs.new_tag_without_v }} | ||
run: make bump-chart | ||
|
||
- name: Update Chart CRDs | ||
if: ${{ inputs.HELM_CHARTS_PATH != '' }} | ||
run: make generate-crds | ||
|
||
# Publish helm chart | ||
- name: Publish Helm chart | ||
if: ${{ inputs.HELM_CHARTS_PATH != '' }} | ||
run: | | ||
helm dependency build ${{ inputs.HELM_CHARTS_PATH }} | ||
helm package ${{ inputs.HELM_CHARTS_PATH }} --destination ./packaged-chart | ||
|
@@ -225,6 +274,7 @@ jobs: | |
# Commit back changes | ||
- name: Commit files | ||
if: ${{ inputs.HELM_CHARTS_PATH != '' }} | ||
run: | | ||
git config --local user.email "${{ inputs.BOT_EMAIL }}" | ||
git config --local user.name "${{ inputs.BOT_USERNAME }}" | ||
|
@@ -233,6 +283,7 @@ jobs: | |
git commit -m "[skip-ci] Update artifacts" -a | ||
- name: Push changes | ||
if: ${{ inputs.HELM_CHARTS_PATH != '' }} | ||
uses: ad-m/github-push-action@master | ||
with: | ||
github_token: ${{ secrets.ADMIN_TOKEN }} | ||
|
@@ -263,4 +314,4 @@ jobs: | |
status: ${{ job.status }} | ||
fields: repo,author,action,eventName,ref,workflow | ||
env: | ||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | ||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |