00-CICD-helm-chart #165
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
name: 00-CICD-helm-chart | |
on: | |
workflow_dispatch: | |
inputs: | |
CHANGE_TAG: | |
required: true | |
default: true | |
type: boolean | |
IMAGE_TAG: | |
# required: true | |
type: string | |
COMPONENT_NAME: | |
# required: true | |
type: string | |
HELM_E2E_TEST: | |
required: true | |
default: true | |
type: boolean | |
# secrets: inherit | |
jobs: | |
input-validator: | |
runs-on: ubuntu-latest | |
steps: | |
- name: input validator | |
run: | | |
if [ ${{ inputs.CHANGE_TAG }} = true ]; then | |
echo "CHANGE_TAG = true, checking if inputs COMPONENT_NAME and IMAGE_TAG are not null" | |
echo "COMPONENT_NAME = ${{ inputs.COMPONENT_NAME }}" | |
echo "IMAGE_TAG = ${{ inputs.IMAGE_TAG }}" | |
if [[ "${{ inputs.COMPONENT_NAME }}" = "" ]] || [[ "${{ inputs.IMAGE_TAG }}" = "" ]]; then | |
echo "One or more inputs are undefined" | |
exit 1 | |
fi | |
echo "We are good to go" | |
elif [ ${{ inputs.CHANGE_TAG }} = false ]; then | |
echo "CHANGE_TAG = false, the workflow will not change any component image tag" | |
fi | |
helm-chart-update: | |
needs: input-validator | |
uses: ./.github/workflows/01-update_tag.yaml | |
with: | |
CHANGE_TAG: ${{ inputs.CHANGE_TAG }} | |
IMAGE_TAG: ${{ inputs.IMAGE_TAG }} | |
COMPONENT_NAME: ${{ inputs.COMPONENT_NAME }} | |
MODE: patch | |
CHART_FILE: charts/kubescape-operator/Chart.yaml | |
secrets: inherit | |
e2e-test: | |
needs: helm-chart-update | |
if: ${{ inputs.HELM_E2E_TEST == true }} | |
uses: ./.github/workflows/02-e2e-test.yaml | |
with: | |
HELM_E2E_TEST: ${{ inputs.HELM_E2E_TEST }} | |
secrets: inherit | |
merge-to-main: | |
needs: [helm-chart-update, e2e-test] | |
if: ${{ (always() && (contains(needs.*.result, 'success') || contains(needs.*.result, 'skipped')) && !(contains(needs.*.result, 'failure')) && !(contains(needs.*.result, 'cancelled'))) }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: merge-to-main | |
uses: "pascalgn/[email protected]" | |
env: | |
GITHUB_TOKEN: "${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}" | |
MERGE_COMMIT_MESSAGE: "Merge to main - PR number: ${{ needs.helm-chart-update.outputs.PR_NUMBER }}" | |
MERGE_ERROR_FAIL: "true" | |
MERGE_METHOD: "merge" | |
MERGE_LABELS: "" | |
UPDATE_LABELS: "" | |
PULL_REQUEST: ${{ needs.helm-chart-update.outputs.PR_NUMBER }} | |
helm-release: | |
needs: [helm-chart-update, merge-to-main] | |
if: ${{ (always() && (contains(needs.*.result, 'success') || contains(needs.*.result, 'skipped')) && !(contains(needs.*.result, 'failure')) && !(contains(needs.*.result, 'cancelled'))) }} | |
with: | |
COMMIT_REF: ${{ needs.helm-chart-update.outputs.COMMIT_REF }} | |
CHARTS_NAME: kubescape-operator | |
uses: ./.github/workflows/03-helm-release.yaml | |
secrets: inherit |