release-testkube-api-charts #1777
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: Releasing Helm charts. | |
on: | |
repository_dispatch: | |
types: | |
[release-testkube-api-charts, release-testkube-operator-charts] | |
env: | |
PROJECT_ID: ${{ secrets.GKE_PROJECT }} | |
GKE_CLUSTER_NAME: ${{ secrets.GKE_CLUSTER_NAME_DEVELOP }} | |
GKE_ZONE: ${{ secrets.GKE_ZONE_DEVELOP }} | |
jobs: | |
release_charts: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Configure Git | |
run: | | |
git config user.name "$GITHUB_ACTOR" | |
git config user.email "[email protected]" | |
- name: Install Helm | |
uses: azure/setup-helm@v3 | |
with: | |
version: v3.10.0 | |
- name: Installing repositories | |
run: | | |
helm repo add helm-charts https://kubeshop.github.io/helm-charts | |
helm repo add bitnami https://raw.githubusercontent.com/bitnami/charts/archive-full-index/bitnami | |
- name: Update main Chart.yaml | |
run: | | |
export RELEASE_VERSION=${{ github.event.client_payload.RELEASE_VERSION }} | |
cd ./scripts | |
chmod +x main_chart_releaser.sh | |
./chart_releaser.sh --helm-chart-folder testkube-${{ github.event.client_payload.SERVICE }} | |
- name: Run chart-releaser | |
uses: helm/[email protected] | |
with: | |
charts_dir: charts | |
mark_as_latest: true | |
env: | |
CR_TOKEN: "${{ secrets.CI_BOT_TOKEN }}" | |
CR_SKIP_EXISTING: true | |
notify_slack_if_helm_chart_release_fails: | |
runs-on: ubuntu-latest | |
needs: release_charts | |
if: always() && (needs.release_charts.result == 'failure') | |
steps: | |
- name: Slack Notification if Helm Release action failed | |
uses: rtCamp/action-slack-notify@v2 | |
env: | |
SLACK_CHANNEL: testkube-logs | |
SLACK_COLOR: ${{ needs.release_charts.result }} # or a specific color like 'good' or '#ff00ff' | |
SLACK_ICON: https://github.com/rtCamp.png?size=48 | |
SLACK_TITLE: Helm Chart release action failed :boom:! | |
SLACK_USERNAME: GitHub | |
SLACK_LINK_NAMES: true | |
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} | |
SLACK_FOOTER: "Kubeshop --> TestKube" | |
refreshing_gh_pages: | |
needs: release_charts | |
runs-on: ubuntu-latest | |
steps: | |
- name: Triggering refresh for GH-pages to make just released charts available | |
run: | | |
curl -s --fail --request POST \ | |
--url https://api.github.com/repos/kubeshop/helm-charts/pages/builds \ | |
--header "Authorization: Bearer $USER_TOKEN" | |
env: | |
# You must create a personal token with repo access as GitHub does | |
# not yet support server-to-server page builds. | |
USER_TOKEN: ${{ secrets.CI_BOT_TOKEN }} | |
checking_that_ghpages_updated: | |
needs: refreshing_gh_pages | |
runs-on: ubuntu-latest | |
steps: | |
- name: Making sure that they are abvailable now. | |
run: | | |
status="" | |
counter=0 | |
while [[ $status != \"built\" ]] | |
do | |
status=$(curl -s \ | |
-H "Accept: application/vnd.github.v3+json" \ | |
https://api.github.com/repos/kubeshop/helm-charts/pages/builds/latest \ | |
--header "Authorization: Bearer $USER_TOKEN" | jq .status) | |
echo "Checking latest GH pages build status --> $status" | |
sleep 5 | |
counter=$(expr $counter + 1) | |
if [[ $status == \"errored\" ]] || [[ $counter == 120 ]]; then | |
echo "Something went wrong. Please check GH's pages issues." | |
exit 1 | |
fi | |
done | |
env: | |
# You must create a personal token with repo access as GitHub does | |
# not yet support server-to-server page builds. | |
USER_TOKEN: ${{ secrets.CI_BOT_TOKEN }} | |
notify_slack_if_release_succeeds: | |
runs-on: ubuntu-latest | |
needs: checking_that_ghpages_updated | |
steps: | |
- name: Slack Notification if the helm release pipeline succeeded. | |
uses: rtCamp/action-slack-notify@v2 | |
env: | |
SLACK_CHANNEL: testkube-logs | |
SLACK_COLOR: ${{ needs.checking_that_ghpages_updated.result }} # or a specific color like 'good' or '#ff00ff' | |
SLACK_ICON: https://github.com/rtCamp.png?size=48 | |
SLACK_TITLE: Helm chart release succeed and GH pages got updated :party_blob:! | |
SLACK_USERNAME: GitHub | |
SLACK_LINK_NAMES: true | |
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} | |
SLACK_FOOTER: "Kubeshop --> TestKube" | |
notify_slack_if_gh_pages_update_failed: | |
runs-on: ubuntu-latest | |
needs: checking_that_ghpages_updated | |
if: always() && (needs.checking_that_ghpages_updated.result == 'failure') | |
steps: | |
- name: Slack Notification if the helm release GH Pages failed. | |
uses: rtCamp/action-slack-notify@v2 | |
env: | |
SLACK_CHANNEL: testkube-logs | |
SLACK_COLOR: ${{ needs.checking_that_ghpages_updated.result }} # or a specific color like 'good' or '#ff00ff' | |
SLACK_ICON: https://github.com/rtCamp.png?size=48 | |
SLACK_TITLE: Helm chart release failed on GH pages update! :boom:! | |
SLACK_USERNAME: GitHub | |
SLACK_LINK_NAMES: true | |
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} | |
SLACK_FOOTER: "Kubeshop --> TestKube" | |
get_agent_version: | |
name: Pass Testkube OSS chart version to cloud-charts repo | |
needs: notify_slack_if_release_succeeds | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install Helm | |
uses: azure/setup-helm@v3 | |
with: | |
version: v3.10.0 | |
- name: Get charts version | |
run: echo agent-version=$(helm show chart ./charts/testkube | grep -E "^version:" | awk '{print $2}') >> $GITHUB_ENV | |
- name: Repository dispatch | |
uses: peter-evans/repository-dispatch@v2 | |
with: | |
token: ${{ secrets.CI_BOT_TOKEN }} | |
repository: kubeshop/testkube-cloud-charts | |
event-type: trigger-workflow-testkube-agent-main | |
client-payload: '{"agentVersion": "${{ env.agent-version }}"}' | |
deploy-to-testkube-dev-gke: | |
name: Deploy | |
runs-on: ubuntu-latest | |
needs: notify_slack_if_release_succeeds | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Configure Git | |
run: | | |
git config user.name "$GITHUB_ACTOR" | |
git config user.email "[email protected]" | |
- uses: google-github-actions/auth@v2 | |
with: | |
credentials_json: ${{ secrets.GKE_SA_KEY }} | |
- id: get-credentials | |
uses: google-github-actions/get-gke-credentials@v2 | |
with: | |
cluster_name: ${{ env.GKE_CLUSTER_NAME }} | |
location: ${{ env.GKE_ZONE }} | |
- name: Install Helm | |
uses: azure/setup-helm@v3 | |
with: | |
version: v3.10.0 | |
- name: Installing repositories | |
run: | | |
helm repo add helm-charts https://kubeshop.github.io/helm-charts | |
helm repo add bitnami https://raw.githubusercontent.com/bitnami/charts/archive-full-index/bitnami | |
# Deploy the Docker image to the GKE cluster | |
- name: Deploy | |
run: |- | |
helm upgrade --install --atomic --timeout 180s testkube helm-charts/testkube --namespace testkube-integration --create-namespace --values ./charts/testkube/values-stage.yaml --debug --set mongodb.livenessProbe.enabled=false --set mongodb.readinessProbe.enabled=false --set testkube-operator.enabled=false | |
notify_slack_if_deploy_dev_succeeds: | |
runs-on: ubuntu-latest | |
needs: deploy-to-testkube-dev-gke | |
steps: | |
- name: Slack Notification if the helm release deployment to DEV GKS succeeded. | |
uses: rtCamp/action-slack-notify@v2 | |
env: | |
SLACK_CHANNEL: testkube-logs | |
SLACK_COLOR: ${{ needs.deploy-to-testkube-dev-gke.result }} # or a specific color like 'good' or '#ff00ff' | |
SLACK_ICON: https://github.com/rtCamp.png?size=48 | |
SLACK_TITLE: Helm chart release successfully deployed into ${{ secrets.GKE_CLUSTER_NAME_DEV }} GKE :party_blob:! | |
SLACK_USERNAME: GitHub | |
SLACK_LINK_NAMES: true | |
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} | |
SLACK_FOOTER: "Kubeshop --> TestKube" | |
notify_slack_if_deploy_dev_failed: | |
runs-on: ubuntu-latest | |
needs: deploy-to-testkube-dev-gke | |
if: always() && (needs.deploy-to-testkube-dev-gke.result == 'failure') | |
steps: | |
- name: Slack Notification if the helm release deployment to DEV GKS failed. | |
uses: rtCamp/action-slack-notify@v2 | |
env: | |
SLACK_CHANNEL: testkube-logs | |
SLACK_COLOR: ${{ needs.deploy-to-testkube-dev-gke.result }} # or a specific color like 'good' or '#ff00ff' | |
SLACK_ICON: https://github.com/rtCamp.png?size=48 | |
SLACK_TITLE: Helm chart release failed to deploy into ${{ secrets.GKE_CLUSTER_NAME_DEV }} GKE! :boom:! | |
SLACK_USERNAME: GitHub | |
SLACK_LINK_NAMES: true | |
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} | |
SLACK_FOOTER: "Kubeshop --> TestKube" | |
update_release_notes: | |
needs: notify_slack_if_release_succeeds | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Get Latest Tag | |
id: get_latest_tag | |
run: | | |
latest_tag=$(git tag -l | grep -E "^testkube-[0-9]+\.[0-9]+\.[0-9]+$" | sort -V | tail -n 1) | |
echo "::set-output name=latest_tag::${latest_tag}" | |
echo $latest_tag | |
- name: Get Previous Tag | |
id: get_previous_tag | |
run: | | |
previous_tag=$(git describe --abbrev=0 --tags ${TAG}^) | |
echo "::set-output name=previous_tag::${previous_tag}" | |
echo $previous_tag | |
env: | |
TAG: ${{ steps.get_latest_tag.outputs.latest_tag }} | |
- name: Generate Changelog | |
id: generate_changelog | |
env: | |
GH_TOKEN: ${{ secrets.CI_BOT_TOKEN }} | |
run: | | |
#!/bin/bash | |
PREVIOUS_TAG=${{ steps.get_previous_tag.outputs.previous_tag }} | |
CURRENT_TAG=${{ steps.get_latest_tag.outputs.latest_tag }} | |
echo $PREVIOUS_TAG | |
echo $CURRENT_TAG | |
MERGED_PRS=$(git log --merges --pretty=format:"- %h: %s (#%b) (@%an)" $PREVIOUS_TAG..$CURRENT_TAG) | |
echo $MERGED_PRS | |
if [ -n "$MERGED_PRS" ]; then | |
echo "# Changelog" > CHANGELOG.md | |
FEATURE_PRS="" | |
FIX_PRS="" | |
OTHER_PRS="" | |
DOCS_PRS="" | |
while IFS= read -r pr; do | |
sha=$(echo "$pr" | awk '{print $1 " " $2}') | |
pr_number=$(echo "$pr" | awk -F'#' '{print "#" $2}' | awk '{print $1}') | |
pr_title=$(echo "$pr" | awk -F'[(]|[)]' '{sub(/^#/, "", $2); print $2}') | |
author=$(echo "$pr" | awk -F'[()]' '{print "(" $4 ")"}') | |
if [[ "$pr_title" == *"feat"* ]]; then | |
FEATURE_PRS+="\n ${sha} ${pr_title} ${pr_number} ${author}" | |
echo "New features" | |
echo $FEATURE_PRS | |
elif [[ "$pr_title" == *"fix"* ]]; then | |
FIX_PRS+="\n ${sha} ${pr_title} ${pr_number} ${author}" | |
echo "Bug fixes" | |
echo $FIX_PRS | |
elif [[ "$pr_title" == *"docs"* ]]; then | |
DOCS_PRS+="\n ${sha} ${pr_title} ${pr_number} ${author}" | |
echo "Documentation updates" | |
echo $DOCS_PRS | |
else | |
OTHER_PRS+="\n ${sha} ${pr_title} ${pr_number} ${author}" | |
echo "Other changes" | |
echo $OTHER_PRS | |
fi | |
done < <(echo "$MERGED_PRS") | |
if [ -n "$FEATURE_PRS" ]; then | |
echo "## Features" >> CHANGELOG.md | |
echo -e "$FEATURE_PRS" >> CHANGELOG.md | |
echo "" >> CHANGELOG.md | |
fi | |
if [ -n "$FIX_PRS" ]; then | |
echo "## Bug Fixes" >> CHANGELOG.md | |
echo -e "$FIX_PRS" >> CHANGELOG.md | |
echo "" >> CHANGELOG.md | |
fi | |
if [ -n "$DOCS_PRS" ]; then | |
echo "## Documentation Updates" >> CHANGELOG.md | |
echo -e "$DOCS_PRS" >> CHANGELOG.md | |
echo "" >> CHANGELOG.md | |
fi | |
if [ -n "$OTHER_PRS" ]; then | |
echo "## Other Changes" >> CHANGELOG.md | |
echo -e "$OTHER_PRS" >> CHANGELOG.md | |
echo "" >> CHANGELOG.md | |
fi | |
echo "Printing changelog" | |
cat CHANGELOG.md | |
echo "Updating release" | |
gh release edit $CURRENT_TAG --notes-file CHANGELOG.md | |
else | |
echo "No merged pull requests found. Adding commits" | |
COMMIT_CHANGELOG=$(git log --pretty=format:"- %s %h (@%an)" $PREVIOUS_TAG..$CURRENT_TAG) | |
echo "# Commit Changelog" > CHANGELOG.md | |
echo "" >> CHANGELOG.md | |
echo "${COMMIT_CHANGELOG}" >> CHANGELOG.md | |
gh release edit $CURRENT_TAG --notes-file CHANGELOG.md | |
fi | |
test_suite_run_dev: | |
name: test suite for DEV GKE. | |
runs-on: ubuntu-latest | |
needs: deploy-to-testkube-dev-gke | |
steps: | |
- uses: google-github-actions/auth@v2 | |
with: | |
credentials_json: ${{ secrets.GKE_SA_KEY }} | |
- id: get-credentials | |
uses: google-github-actions/get-gke-credentials@v2 | |
with: | |
cluster_name: ${{ env.GKE_CLUSTER_NAME }} | |
location: ${{ env.GKE_ZONE }} | |
- name: Install testkube kubectl plugin | |
run: bash < <(curl -sSLf https://get.testkube.io ) | |
- name: Disable telemetry (action) | |
id: disable_telemetry | |
uses: kubeshop/testkube-docker-action@v1 | |
with: | |
command: disable | |
resource: telemetry | |
- name: Checkout tests from main Testkube repo | |
uses: actions/checkout@v3 | |
with: | |
repository: kubeshop/testkube | |
path: testkube-repo | |
ref: main | |
- name: Executor tests - create/update and schedule all executor tests (with CLI) | |
working-directory: ./testkube-repo | |
run: chmod +x ./test/scripts/executor-tests/run.sh && ./test/scripts/executor-tests/run.sh -c -s # (create/update, schedule) - don't execute | |
- name: Delete Postman Sanity test (with CLI) | |
working-directory: ./testkube-repo | |
run: |- | |
# enabling debug mode | |
set -x | |
kubectl -n testkube delete test sanity --ignore-not-found=true | |
kubectl -n testkube delete secret sanity-secrets --ignore-not-found=true | |
- name: Create Postman Sanity test (action) | |
id: create_postman_sanity_test | |
uses: kubeshop/testkube-docker-action@v1 | |
with: | |
command: create | |
resource: test | |
parameters: "-f ./testkube-repo/test/postman/TestKube-Sanity.postman_collection.json --name sanity --type postman/collection -v api_uri=http://testkube-api-server:8088 -v test_api_uri=http://testkube-api-server:8088 -v test_type=postman/collection -v test_name=fill-me -v execution_name=fill-me" | |
- name: Run Postman Sanity test (action) | |
id: run_postman_sanity_test | |
uses: kubeshop/testkube-docker-action@v1 | |
with: | |
command: run | |
resource: test | |
parameters: "sanity -f" | |
- name: Create/update Dashboard E2E tests (from CRD) | |
working-directory: ./testkube-repo | |
run: |- | |
# enabling debug mode | |
set -x | |
kubectl apply -f ./test/dashboard-e2e/crd/crd.yaml -ntestkube | |
- name: (Re)create demo testsuite | |
working-directory: ./testkube-repo | |
run: |- | |
# enabling debug mode | |
set -x | |
kubectl -n testkube delete testsuite demo-testsuite --ignore-not-found=true | |
kubectl testkube create testsuite -f ./test/suites/demo-testsuite.json --name demo-testsuite | |
- name: Run demo testsuite (CLI) | |
run: kubectl testkube run testsuite demo-testsuite -f | |
notify_slack_if_test_suite_dev_succeeds: | |
runs-on: ubuntu-latest | |
needs: test_suite_run_dev | |
steps: | |
- name: Slack Notification if the test suite run on DEV GKS succeeded. | |
uses: rtCamp/action-slack-notify@v2 | |
env: | |
SLACK_CHANNEL: testkube-logs | |
SLACK_COLOR: ${{ needs.test_suite_run_dev.result }} # or a specific color like 'good' or '#ff00ff' | |
SLACK_ICON: https://github.com/rtCamp.png?size=48 | |
SLACK_TITLE: Test suite successfully run against ${{ secrets.GKE_CLUSTER_NAME_DEV }} GKE :party_blob:! | |
SLACK_USERNAME: GitHub | |
SLACK_LINK_NAMES: true | |
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} | |
SLACK_FOOTER: "Kubeshop --> TestKube" | |
notify_slack_if_test_suite_failed: | |
runs-on: ubuntu-latest | |
needs: test_suite_run_dev | |
if: always() && (needs.test_suite_run_dev.result == 'failure') | |
steps: | |
- name: Slack Notification if the test suite run on DEV GKS failed. | |
uses: rtCamp/action-slack-notify@v2 | |
env: | |
SLACK_CHANNEL: testkube-logs | |
SLACK_COLOR: ${{ needs.test_suite_run_dev.result }} # or a specific color like 'good' or '#ff00ff' | |
SLACK_ICON: https://github.com/rtCamp.png?size=48 | |
SLACK_TITLE: Test suite FAILED to run on ${{ secrets.GKE_CLUSTER_NAME_DEV }} GKE! :boom:! | |
SLACK_USERNAME: GitHub | |
SLACK_LINK_NAMES: true | |
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} | |
SLACK_FOOTER: "Kubeshop --> TestKube" |