Skip to content

Commit

Permalink
Main helm chart deployment (#1279)
Browse files Browse the repository at this point in the history
  • Loading branch information
huseyinbabal authored Oct 6, 2023
1 parent 7c230f7 commit 130b555
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 2 deletions.
22 changes: 21 additions & 1 deletion .github/workflows/branch-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,24 @@ env:
IMAGE_TAG: v9.99.9-dev # TODO: Use commit hash tag to make the predictable builds for each commit on branch

jobs:
extract-metadata:
runs-on: ubuntu-latest
outputs:
versions: ${{ steps.extract-version.outputs.versions }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract version
id: extract-version
run: |
IMAGE_VERSION=$(git rev-parse --short HEAD)
echo "versions={\"image-version\":[\"v9.99.9-dev\",\"0.0.0-${IMAGE_VERSION}\"]}" >> $GITHUB_OUTPUT
build:
needs: [extract-metadata]
strategy:
matrix: ${{ fromJson(needs.extract-metadata.outputs.versions) }}
runs-on: ubuntu-latest
env:
GO111MODULE: on
Expand Down Expand Up @@ -45,9 +62,12 @@ jobs:
install-only: true
version: latest
- name: Run GoReleaser
run: make release-snapshot
run: |
make release-snapshot
env:
ANALYTICS_API_KEY: ${{ secrets.ANALYTICS_API_KEY }}
GORELEASER_CURRENT_TAG: ${{ matrix.image-version }}
IMAGE_TAG: ${{ matrix.image-version }}
- name: Install Helm
uses: azure/setup-helm@v3
with:
Expand Down
65 changes: 65 additions & 0 deletions .github/workflows/publish-chart.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Publish main helm chart

on:
push:
paths:
- 'helm/**'
- '.github/workflows/**'
branches:
- 'main'

env:
git-user: github-actions[bot]
git-email: 41898282+github-actions[bot]@users.noreply.github.com
HELM_DOCS_VERSION: 1.11.0
CHART_REPOSITORY: https://storage.googleapis.com/dev-botkube-latest-main-charts
LATEST_PLUGIN_INDEX_URL: https://storage.googleapis.com/botkube-plugins-latest/plugins-index.yaml
LATEST_X_PLUGIN_TPLS_URL: github.com/kubeshop/botkube//cmd/executor/exec/templates?ref=main

jobs:
process-chart:
name: Process Chart Updates
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4

- name: Update Chart Version in YAML Files
id: process-chart
run: |
VERSION_WITH_SHA_SHORT="0.0.0-$(git rev-parse --short HEAD)"
CHART_VERSION="0.0.0-${SHA_SHORT}"
HELM_FOLDER=$(echo "${{ github.workspace }}/helm")
CHART_CURRENT_VERSION=$(sed -nE 's/^version\s*:\s*([^\s\/]*).*/\1/p' ${HELM_FOLDER}/botkube/Chart.yaml)
CHART_DEV_VERSION="v9.99.9-dev"
find ${HELM_FOLDER} -name "*.yaml" -exec sed -i "s/${CHART_CURRENT_VERSION}/${CHART_VERSION}/g" {} +
find ${HELM_FOLDER} -name "*.yaml" -exec sed -i "s/${CHART_DEV_VERSION}/${CHART_VERSION}/g" {} +
echo "chart_version=$(echo $VERSION_WITH_SHA_SHORT)" >> $GITHUB_OUTPUT
- name: Set up chart-testing
uses: helm/chart-testing-action@v2.2.1

- name: Run chart-testing
working-directory: ${{ github.workspace }}/helm
run: |
ct lint --all --chart-dirs . --config ./ct/lint-cfg.yaml --lint-conf ./ct/lint-rules.yaml
- name: Publish Chart
run: |
helm package -d ${{ github.workspace }}/main-chart ./helm/botkube --version ${{ steps.process-chart.outputs.chart_version }}
helm repo index --url "${{ env.CHART_REPOSITORY }}" --merge ${{ github.workspace }}/main-chart/index.yaml ${{ github.workspace }}/main-chart/
- name: GCP auth
uses: 'google-github-actions/auth@v1'
with:
credentials_json: ${{ secrets.PLUGINS_BUCKET_CREDENTIALS }}

- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v1'

- name: Upload chart to GCS
uses: google-github-actions/upload-cloud-storage@v1
with:
path: ${{ github.workspace }}/main-chart
destination: 'botkube-latest-main-charts/'
parent: false
2 changes: 1 addition & 1 deletion hack/goreleaser.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ IMAGE_REPOSITORY="${IMAGE_REPOSITORY:-kubeshop/botkube}"
CFG_EXPORTER_IMAGE_REPOSITORY="${CFG_EXPORTER_IMAGE_REPOSITORY:-kubeshop/botkube-config-exporter}"
IMAGE_SAVE_LOAD_DIR="${IMAGE_SAVE_LOAD_DIR:-/tmp/botkube-images}"
IMAGE_PLATFORM="${IMAGE_PLATFORM:-linux/amd64}"
GORELEASER_CURRENT_TAG="${GORELEASER_CURRENT_TAG:-v9.99.9-dev}"

prepare() {
export DOCKER_CLI_EXPERIMENTAL="enabled"
Expand All @@ -16,7 +17,6 @@ prepare() {

release_snapshot() {
prepare
export GORELEASER_CURRENT_TAG=v9.99.9-dev
goreleaser release --clean --snapshot --skip-publish

# Push images
Expand Down

0 comments on commit 130b555

Please sign in to comment.