Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move workflows to github actions #860

Merged
merged 3 commits into from
Sep 7, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 0 additions & 76 deletions .circleci/config.yml

This file was deleted.

12 changes: 12 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,15 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: make license-check

- name: Build
run: |
make generate

- name: Lint
run: |
make lint

- name: Run tests
run: |
make test
103 changes: 103 additions & 0 deletions .github/workflows/helm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: Helm chart

on:
push:
branches:
- master
tags:
- "chart/**/[0-9]+.[0-9]+.[0-9]+"
- "chart/**/[0-9]+.[0-9]+.[0-9]+-dev.[0-9]+"
- "chart/**/[0-9]+.[0-9]+.[0-9]+-rc .[0-9]+"
asdwsda marked this conversation as resolved.
Show resolved Hide resolved
pull_request:

env:
HELM_CHART_NAME: kafka-operator
HELM_CHART_PATH: "${{ github.workspace }}/charts/kafka-operator"
HELM_PLUGIN_CHARTMUSEUM_PUSH_VERSION: 0.9.0
HELM_PUSH_REPOSITORY_NAME: banzaicloud-stable
HELM_VERSION: 3.6.0

jobs:
helm:
name: Helm
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2

- uses: azure/setup-helm@v1
with:
version: ${{ env.HELM_VERSION }}

- name: Add Helm repositories
run: |
helm repo add banzaicloud-stable "https://kubernetes-charts.banzaicloud.com"
helm repo add incubator "https://charts.helm.sh/incubator"
helm repo add stable "https://charts.helm.sh/stable"

- name: Update Helm repositories
run: helm repo update

- name: Lint Helm chart
run: helm lint "${{ env.HELM_CHART_PATH }}"

- name: Update Helm chart dependencies
run: helm dependency update "${{ env.HELM_CHART_PATH }}"

- name: Package Helm chart
id: package-chart
run: |
HELM_PACKAGE_OUTPUT=$(helm package "${{ env.HELM_CHART_PATH }}") || exit 1
HELM_PACKAGE_PATH="${HELM_PACKAGE_OUTPUT##"Successfully packaged chart and saved it to: "}"

echo "HELM_PACKAGE_PATH=${HELM_PACKAGE_PATH}"
echo ::set-output name=helm_package_path::${HELM_PACKAGE_PATH}

- name: Set Git refname
id: set-git-refname
run: |
GIT_REFNAME="$(echo "${{ github.ref }}" | sed -r 's@refs/(heads|pull|tags)/@@g')"

echo "GIT_REFNAME=${GIT_REFNAME}"
echo ::set-output name=git_refname::${GIT_REFNAME}

- name: Set Helm push enabled
id: set-helm-push-enabled
run: |
HELM_PUSH_ENABLED=""
if [ "${{ github.event_name }}" == "push" ] && echo "${{ steps.set-git-refname.outputs.git_refname }}" | grep -E -q "^chart/${{ env.HELM_CHART_NAME }}/[0-9]+.[0-9]+.[0-9]+**"; then
HELM_PUSH_ENABLED=1
else
printf >&2 "Unstable chart (%s) from %s event, chart will not be pushed" "${{ steps.set-git-refname.outputs.git_refname }}" "${{ github.event_name }}"
fi

echo "HELM_PUSH_ENABLED=${HELM_PUSH_ENABLED}"
echo ::set-output name=helm_push_enabled::${HELM_PUSH_ENABLED}

- if: ${{ steps.set-helm-push-enabled.outputs.helm_push_enabled == 1 }}
name: Check Helm chart version in repository
run: |
EXPECTED_CHART_VERSION="$(echo "${{ steps.set-git-refname.outputs.git_refname }}" | awk -F '/' '{print $NF}')" || exit 1
ACTUAL_CHART_VERSION="$(awk '/version: [0-9]+\.[0-9]+\.[0-9]+/ {print $2}' "${{ env.HELM_CHART_PATH }}/Chart.yaml")" || exit 1

if [ "${EXPECTED_CHART_VERSION}" != "${ACTUAL_CHART_VERSION}" ]; then
printf >&2 "chart version mismatches, name: %s, expected version (from tag): %s, actual version (from chart): %s" "${{ env.HELM_CHART_NAME }}" "${EXPECTED_CHART_VERSION}" "${ACTUAL_CHART_VERSION}"
exit 1
fi

if helm search repo "${{ env.HELM_PUSH_REPOSITORY_NAME }}/${{ env.HELM_CHART_NAME }}" --version "${ACTUAL_CHART_VERSION}" --output json | jq --exit-status 'length > 0'; then
printf >&2 "chart version already exists in the repository, repository: %s, name: %s, version: %s" "${{ env.HELM_PUSH_REPOSITORY_NAME }}" "${{ env.HELM_CHART_NAME }}" "${ACTUAL_CHART_VERSION}"
exit 1
fi

- if: ${{ steps.set-helm-push-enabled.outputs.helm_push_enabled == 1 }}
name: Install Helm ChartMuseum push plugin
run: helm plugin install "https://github.com/chartmuseum/helm-push.git" --version "${{ env.HELM_PLUGIN_CHARTMUSEUM_PUSH_VERSION }}"

- if: ${{ steps.set-helm-push-enabled.outputs.helm_push_enabled == 1 }}
name: Push Helm chart
env:
HELM_REPO_PASSWORD: ${{ secrets.HELM_REPO_PASSWORD }}
HELM_REPO_USERNAME: ${{ secrets.HELM_REPO_USERNAME }}
run: helm push "${{ steps.package-chart.outputs.helm_package_path }}" "${{ env.HELM_PUSH_REPOSITORY_NAME }}"