This repository has been archived by the owner on Dec 21, 2023. It is now read-only.
build(deps): Auto-update go-utils to latest version #22312
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: CI | |
on: | |
# always execute docker build when something is pushed to master or a maintenance branch | |
push: | |
branches: | |
- 'master' | |
- '[0-9]+.[1-9][0-9]*.x' | |
# in addition, execute for pull requests to those branches | |
pull_request: | |
branches: | |
- 'master' | |
- '[0-9]+.[1-9][0-9]*.x' | |
env: | |
GO_VERSION: "~1.20" | |
INSTALLER_FOLDER: "installer/" | |
BRIDGE_ARTIFACT_PREFIX: "BRIDGE" | |
BRIDGE_UI_TEST_ARTIFACT_PREFIX: "BRIDGE_UI_TEST" | |
BRIDGE_CODE_STYLE_ARTIFACT_PREFIX: "BRIDGE_CODE_STYLE" | |
BRIDGE_SERVER_ARTIFACT_PREFIX: "BRIDGE_SERVER" | |
API_ARTIFACT_PREFIX: "API" | |
APPROVAL_SVC_ARTIFACT_PREFIX: "APPROVAL_SVC" | |
DISTRIBUTOR_ARTIFACT_PREFIX: "DISTRIBUTOR" | |
CLI_ARTIFACT_PREFIX: "CLI" | |
SHIPYARD_CONTROLLER_ARTIFACT_PREFIX: "SHIPYARD_CONTROLLER" | |
SECRET_SVC_ARTIFACT_PREFIX: "SECRET_SVC" | |
RESOURCE_SVC_ARTIFACT_PREFIX: "RESOURCE_SVC" | |
REMEDIATION_SVC_ARTIFACT_PREFIX: "REMEDIATION_SVC" | |
LIGHTHOUSE_SVC_ARTIFACT_PREFIX: "LIGHTHOUSE_SVC" | |
MONGODB_DS_ARTIFACT_PREFIX: "MONGODB_DS" | |
STATISTICS_SVC_ARTIFACT_PREFIX: "STATISTICS_SVC" | |
WEBHOOK_SVC_ARTIFACT_PREFIX: "WEBHOOK_SVC" | |
BRIDGE_ARTIFACT: "bridge2" | |
BRIDGE_FOLDER: "bridge/" | |
BRIDGE_DOCKER_TEST_TARGET: "builder-test-unit" | |
BRIDGE_UI_TEST_ARTIFACT: "bridge2" | |
BRIDGE_UI_TEST_FOLDER: "bridge/" | |
BRIDGE_UI_TEST_DOCKER_TEST_TARGET: "builder-test-ui" | |
BRIDGE_UI_TEST_SHOULD_PUSH_IMAGE: "false" | |
BRIDGE_SERVER_ARTIFACT: "bridge2" | |
BRIDGE_SERVER_FOLDER: "bridge/" | |
BRIDGE_SERVER_DOCKER_TEST_TARGET: "bridge-server-test" | |
BRIDGE_SERVER_SHOULD_PUSH_IMAGE: "false" | |
BRIDGE_CODE_STYLE_ARTIFACT: "bridge2" | |
BRIDGE_CODE_STYLE_FOLDER: "bridge/" | |
BRIDGE_CODE_STYLE_DOCKER_TEST_TARGET: "builder-code-style" | |
BRIDGE_CODE_STYLE_SHOULD_PUSH_IMAGE: "false" | |
API_ARTIFACT: "api" | |
API_FOLDER: "api/" | |
API_DOCKER_TEST_TARGET: "builder-test" | |
APPROVAL_SVC_ARTIFACT: "approval-service" | |
APPROVAL_SVC_FOLDER: "approval-service/" | |
APPROVAL_SVC_DOCKER_TEST_TARGET: "builder-test" | |
DISTRIBUTOR_ARTIFACT: "distributor" | |
DISTRIBUTOR_FOLDER: "distributor/" | |
DISTRIBUTOR_DOCKER_TEST_TARGET: "builder-test" | |
CLI_ARTIFACT: "cli" | |
CLI_FOLDER: "cli/" | |
CLI_DOCKER_TEST_TARGET: "builder-test" | |
SHIPYARD_CONTROLLER_ARTIFACT: "shipyard-controller" | |
SHIPYARD_CONTROLLER_FOLDER: "shipyard-controller/" | |
SHIPYARD_CONTROLLER_DOCKER_TEST_TARGET: "builder-test" | |
SECRET_SVC_ARTIFACT: "secret-service" | |
SECRET_SVC_FOLDER: "secret-service/" | |
SECRET_SVC_DOCKER_TEST_TARGET: "builder-test" | |
RESOURCE_SVC_ARTIFACT: "resource-service" | |
RESOURCE_SVC_FOLDER: "resource-service/" | |
RESOURCE_SVC_DOCKER_TEST_TARGET: "builder-test" | |
REMEDIATION_SVC_ARTIFACT: "remediation-service" | |
REMEDIATION_SVC_FOLDER: "remediation-service/" | |
REMEDIATION_SVC_DOCKER_TEST_TARGET: "builder-test" | |
LIGHTHOUSE_SVC_ARTIFACT: "lighthouse-service" | |
LIGHTHOUSE_SVC_FOLDER: "lighthouse-service/" | |
LIGHTHOUSE_SVC_DOCKER_TEST_TARGET: "builder-test" | |
MONGODB_DS_ARTIFACT: "mongodb-datastore" | |
MONGODB_DS_FOLDER: "mongodb-datastore/" | |
MONGODB_DS_DOCKER_TEST_TARGET: "builder-test" | |
STATISTICS_SVC_ARTIFACT: "statistics-service" | |
STATISTICS_SVC_FOLDER: "statistics-service/" | |
STATISTICS_SVC_DOCKER_TEST_TARGET: "builder-test" | |
WEBHOOK_SVC_ARTIFACT: "webhook-service" | |
WEBHOOK_SVC_FOLDER: "webhook-service/" | |
WEBHOOK_SVC_DOCKER_TEST_TARGET: "builder-test" | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
prepare_ci_run: | |
name: Prepare CI Run | |
# Prepare CI Run looks at what has been changed in this commit/PR/... and determines which artifacts should be | |
# built afterwards (in other jobs that depend on this one). | |
runs-on: ubuntu-22.04 | |
outputs: # declare what this job outputs (so it can be re-used for other jobs) | |
# build config | |
BUILD_EVERYTHING: ${{ steps.build_everything.outputs.BUILD_EVERYTHING }} | |
BUILD_INSTALLER: ${{ steps.check_modified_files.outputs.BUILD_INSTALLER }} | |
BUILD_CLI: ${{ steps.check_modified_files.outputs.BUILD_CLI }} | |
BUILD_MATRIX: ${{ steps.check_modified_files.outputs.BUILD_MATRIX }} | |
BUILD_MATRIX_EMPTY: ${{ steps.check_modified_files.outputs.BUILD_MATRIX_EMPTY }} | |
# metadata | |
GIT_SHA: ${{ steps.extract_branch.outputs.GIT_SHA }} | |
BRANCH: ${{ steps.extract_branch.outputs.BRANCH }} | |
BRANCH_SLUG: ${{ steps.extract_branch.outputs.BRANCH_SLUG }} | |
VERSION: ${{ steps.get_version.outputs.VERSION }} | |
KEPTN_SPEC_VERSION: ${{ steps.get_version.outputs.KEPTN_SPEC_VERSION }} | |
DATETIME: ${{ steps.get_datetime.outputs.DATETIME }} | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # need to checkout "all commits" for certain features to work (e.g., get all changed files) | |
submodules: 'true' | |
- name: Get changed files | |
id: changed_files | |
uses: tj-actions/changed-files@v39 | |
continue-on-error: true | |
- name: Prepare for build-everything run | |
if: (github.event_name == 'push') || (github.event_name == 'workflow_dispatch') || (contains(github.event.pull_request.labels.*.name, 'CI:trigger-build-everything')) | |
id: build_everything | |
run: | | |
BUILD_EVERYTHING=true | |
echo "BUILD_EVERYTHING=$(echo ${BUILD_EVERYTHING})" >> $GITHUB_OUTPUT | |
- name: Prepare artifacts with changes | |
id: check_modified_files | |
env: | |
BUILD_EVERYTHING: ${{ steps.build_everything.outputs.BUILD_EVERYTHING }} | |
GITHUB_REF_PROTECTED: ${{ env.GITHUB_REF_PROTECTED }} | |
run: | | |
./gh-actions-scripts/prepare_changed_artifacts.sh "${{ steps.changed_files.outputs.all_changed_files }}" | |
- name: Extract branch name | |
id: extract_branch | |
# see https://github.com/keptn/gh-action-extract-branch-name for details | |
uses: keptn/gh-action-extract-branch-name@main | |
- name: Get the version | |
id: get_version | |
env: | |
BRANCH: ${{ steps.extract_branch.outputs.BRANCH }} | |
BRANCH_SLUG: ${{ steps.extract_branch.outputs.BRANCH_SLUG }} | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
shell: bash | |
run: | | |
# determine version | |
npx release-please@^14.11.0 release-pr \ | |
--token="$GH_TOKEN" \ | |
--repo-url=keptn/keptn \ | |
--dry-run=true > release-please-output | |
GIT_NEXT_TAG="" | |
if grep -q 'title: build(release):' 'release-please-output'; then | |
GIT_NEXT_TAG=$(cat release-please-output | grep 'title: build(release):' | cut -d ' ' -f3) | |
else | |
GIT_NEXT_TAG='0.0.0' | |
fi | |
echo "GIT_NEXT_TAG=${GIT_NEXT_TAG}" | |
if [[ "$BRANCH" == "master" ]]; then | |
# master branch = latest | |
VERSION="${GIT_NEXT_TAG}-dev" | |
else | |
# Feature/Development Branch - use last tag with branch slug | |
VERSION="${GIT_NEXT_TAG}-dev-${BRANCH_SLUG}" | |
fi | |
# determine keptn spec version | |
git submodule update --init | |
cd specification | |
KEPTN_SPEC_VERSION=$(git describe --tags) | |
echo "VERSION=${VERSION}" | |
echo "KEPTN_SPEC_VERSION=${KEPTN_SPEC_VERSION}" | |
echo "VERSION=${VERSION}" >> "$GITHUB_OUTPUT" | |
echo "KEPTN_SPEC_VERSION=${KEPTN_SPEC_VERSION}" >> "$GITHUB_OUTPUT" | |
- name: Get current date and time | |
id: get_datetime | |
run: | | |
DATETIME=$(date +'%Y%m%d%H%M') | |
echo "DATETIME=$DATETIME" >> "$GITHUB_OUTPUT" | |
store-output-in-build-config: | |
name: "Store output of last step in build-config.env" | |
needs: prepare_ci_run | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Create build config file | |
env: | |
BRANCH: ${{ needs.prepare_ci_run.outputs.BRANCH }} | |
BRANCH_SLUG: ${{ needs.prepare_ci_run.outputs.BRANCH_SLUG }} | |
BUILD_EVERYTHING: ${{ needs.prepare_ci_run.outputs.BUILD_EVERYTHING }} | |
VERSION: ${{ needs.prepare_ci_run.outputs.VERSION }} | |
DATETIME: ${{ needs.prepare_ci_run.outputs.DATETIME }} | |
GIT_SHA: ${{ needs.prepare_ci_run.outputs.GIT_SHA }} | |
run: | | |
echo "BRANCH=${BRANCH}" >> build-config.env | |
echo "BRANCH_SLUG=${BRANCH_SLUG}" >> build-config.env | |
echo "BUILD_EVERYTHING=${BUILD_EVERYTHING}" >> build-config.env | |
echo "VERSION=${VERSION}" >> build-config.env | |
echo "DATETIME=${DATETIME}" >> build-config.env | |
echo "GIT_SHA=${GIT_SHA}" >> build-config.env | |
- name: Upload build config as artifact | |
id: upload_build_config | |
uses: actions/upload-artifact@v3 | |
with: | |
name: build-config | |
path: build-config.env | |
####################################################################### | |
# UNIT TEST AND BUILD PRODUCTION IMAGES | |
####################################################################### | |
unit-tests-and-build: | |
name: Test and Build | |
needs: prepare_ci_run | |
if: needs.prepare_ci_run.outputs.BUILD_MATRIX_EMPTY == 'false' | |
strategy: | |
matrix: ${{ fromJson(needs.prepare_ci_run.outputs.BUILD_MATRIX) }} | |
uses: ./.github/workflows/test-and-build-docker-images.yml | |
secrets: inherit | |
with: | |
artifact: ${{ matrix.config.artifact }} | |
tags: | | |
ghcr.io/keptn/${{ matrix.config.artifact }}:${{ needs.prepare_ci_run.outputs.VERSION }} | |
ghcr.io/keptn/${{ matrix.config.artifact }}:${{ needs.prepare_ci_run.outputs.VERSION }}.${{ needs.prepare_ci_run.outputs.DATETIME }} | |
should-run: ${{ matrix.config.should-run }} | |
should-push-image: ${{ matrix.config.should-push-image == 'true' && (( github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository ) || ( github.event_name == 'push' )) && github.actor != 'renovate[bot]' && github.actor != 'dependabot[bot]' }} | |
docker-test-target: ${{ matrix.config.docker-test-target }} | |
working-dir: ${{ matrix.config.working-dir }} | |
version: ${{ needs.prepare_ci_run.outputs.VERSION }} | |
datetime: ${{ needs.prepare_ci_run.outputs.DATETIME }} | |
gitSha: ${{ needs.prepare_ci_run.outputs.GIT_SHA }} | |
build-everything: ${{ needs.prepare_ci_run.outputs.BUILD_EVERYTHING }} | |
build-installer: ${{ needs.prepare_ci_run.outputs.BUILD_INSTALLER }} | |
############################################################################ | |
# Build CLI # | |
############################################################################ | |
build-cli: | |
name: Build Keptn CLI | |
needs: [prepare_ci_run] | |
if: (needs.prepare_ci_run.outputs.BUILD_EVERYTHING == 'true') || (needs.prepare_ci_run.outputs.BUILD_CLI == 'true') | |
uses: ./.github/workflows/build-cli.yml | |
with: | |
branch: ${{ needs.prepare_ci_run.outputs.BRANCH }} | |
version: ${{ needs.prepare_ci_run.outputs.VERSION }} | |
datetime: ${{ needs.prepare_ci_run.outputs.DATETIME }} | |
############################################################################ | |
# Build Helm Charts (only relevant for build_everything) # | |
############################################################################ | |
helm_charts_build: | |
name: Build Helm Charts | |
needs: [prepare_ci_run, unit-tests-and-build] | |
if: (needs.prepare_ci_run.outputs.BUILD_EVERYTHING == 'true') || (needs.prepare_ci_run.outputs.BUILD_INSTALLER == 'true') | |
uses: ./.github/workflows/build-helm-charts.yml | |
secrets: inherit | |
with: | |
branch: ${{ needs.prepare_ci_run.outputs.BRANCH }} | |
version: ${{ needs.prepare_ci_run.outputs.VERSION }} | |
keptn-spec-version: ${{ needs.prepare_ci_run.outputs.KEPTN_SPEC_VERSION }} | |
datetime: ${{ needs.prepare_ci_run.outputs.DATETIME }} | |
helm_charts_upload: | |
name: Publish helm charts to dev repo | |
needs: [prepare_ci_run, helm_charts_build, unit-tests-and-build] | |
if: ((needs.prepare_ci_run.outputs.BUILD_EVERYTHING == 'true') || (needs.prepare_ci_run.outputs.BUILD_INSTALLER == 'true')) && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)) | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout helm-charts repo | |
uses: actions/checkout@v4 | |
with: | |
repository: keptn/helm-charts-dev | |
path: helm-charts-dev | |
ref: gh-pages | |
token: ${{ secrets.KEPTN_BOT_TOKEN }} | |
- name: Configure Git | |
working-directory: helm-charts-dev | |
env: | |
KEPTN_BOT_NAME: "Keptn Bot" | |
KEPTN_BOT_EMAIL: "keptn-bot <86361500+keptn-bot@users.noreply.github.com>" | |
run: | | |
git config user.name "$KEPTN_BOT_NAME" | |
git config user.email "$KEPTN_BOT_EMAIL" | |
- name: Install Helm | |
uses: azure/setup-helm@v3 | |
with: | |
version: v3.7.2 | |
- name: Download Helm Chart artifacts | |
id: download_helm_chart | |
uses: actions/download-artifact@v3 | |
with: | |
name: keptn-installer | |
path: dist/keptn-installer | |
- name: Upload helm charts to dev repo | |
env: | |
RELEASE_TAG: ${{ needs.prepare_ci_run.outputs.VERSION }} | |
run: | | |
mv ./dist/keptn-installer/*.tgz ./helm-charts-dev/packages | |
cd ./helm-charts-dev | |
helm repo index ./ --url https://charts-dev.keptn.sh/ --merge ./index.yaml | |
git add *.tgz | |
git add index.yaml | |
git commit --signoff -m "Keptn Dev Version $RELEASE_TAG" | |
git push |