diff --git a/.circleci/config.yml b/.circleci/config.yml index b109f7f..c79c357 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -23,6 +23,7 @@ commands: else echo "export DEPLOY_TAG=$(echo $CIRCLE_TAG)" >> $BASH_ENV fi + jobs: lint-test: machine: @@ -95,9 +96,33 @@ jobs: source $BASH_ENV ct install --config ct.yaml --helm-extra-set-args "--set=image.tag=$DEPLOY_TAG" --target-branch master + publish_chart: + executor: + name: cci-common/ci_image + flavor: "-google" + parameters: + version: + type: string + steps: + - checkout + - attach_workspace: + at: /tmp + - cci-common/install_gcloud + - cci-common/gcloud_login + - run: + name: "Package and push helm chart" + command: | + source /tmp/secrets || true + + export GOOGLE_APPLICATION_CREDENTIALS=/tmp/cluster_secret.json + + gcloud auth application-default print-access-token | helm registry login -u oauth2accesstoken --password-stdin https://$K8S_CLUSTER_artifact_registry_url + + helm package charts/nightscaler --app-version << parameters.version >> --version << parameters.version >> + helm push nightscaler-<< parameters.version >>.tgz oci://$K8S_CLUSTER_artifact_registry_url/$K8S_CLUSTER_artifact_registry_project/public-docker/chart workflows: - build: + build-n-publish: jobs: - secret-injector/dump-secrets-yaml: secret-file: secrets-ci.yaml @@ -105,7 +130,7 @@ workflows: <<: *prod_context - cci-common/go_test_unit: go_version: "1.21.3" - resource_class: large + resource_class: xlarge requires: - secret-injector/dump-secrets-yaml - cci-common/go_test_sonar: @@ -129,3 +154,10 @@ workflows: - cci-common/go_test_unit - cci-common/go_test_sonar - cci-common/build_n_push_docker + - publish_chart: + version: $DEPLOY_TAG + pre-steps: + - generate_docker_tag + <<: *prod_context + requires: + - lint-test diff --git a/.github/release-drafter-helm.yml b/.github/release-drafter-helm.yml deleted file mode 100644 index f9de9f8..0000000 --- a/.github/release-drafter-helm.yml +++ /dev/null @@ -1,43 +0,0 @@ -name-template: "chart-$RESOLVED_VERSION" -tag-template: "chart-$RESOLVED_VERSION" -include-labels: - - helm-chart -tag-prefix: "chart-" -categories: - - title: Breaking Changes 💥 - labels: - - breaking-change - - title: New Features 🎉 - labels: - - new-feature - - title: Bug Fixes 🐛 - labels: - - patch - - title: Dependencies 📌 - labels: - - dependencies - - title: Other Changes 🛠 -change-template: "- $TITLE @$AUTHOR (#$NUMBER)" -change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks. -version-resolver: - major: - labels: - - "major" - - "breaking-change" - minor: - labels: - - "minor" - - "new-feature" - patch: - labels: - - "patch" - default: patch -autolabeler: - - label: helm-chart - files: - - "chart/**" -template: | - - $CHANGES - - **Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...chart-$RESOLVED_VERSION diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index 007f991..8bb99cf 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -1,7 +1,5 @@ name-template: "v$RESOLVED_VERSION" tag-template: "v$RESOLVED_VERSION" -include-labels: - - app tag-prefix: "v" categories: - title: Breaking Changes 💥 @@ -32,12 +30,7 @@ version-resolver: labels: - "patch" default: patch -autolabeler: - - label: app - files: - - "!chart/**" template: | - $CHANGES **Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION diff --git a/.github/workflows/release-chart.yml b/.github/workflows/release-chart.yml deleted file mode 100644 index dd3e0da..0000000 --- a/.github/workflows/release-chart.yml +++ /dev/null @@ -1,84 +0,0 @@ -name: Release Chart - -on: - push: - tags: - - "chart-*" - -jobs: - release: - runs-on: ubuntu-latest - permissions: - contents: write - # packages: write - 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 "$GITHUB_ACTOR@users.noreply.github.com" - - - uses: cardinalby/git-get-release-action@v1 - name: Get Latest Chart Release - id: get_chart_release - env: - GITHUB_TOKEN: ${{ github.token }} - with: - latest: true - draft: false - releaseNameRegEx: '^chart-[0-9]+\.[0-9]+\.[0-9]+$' - - - uses: cardinalby/git-get-release-action@v1 - name: Get Latest App Release - id: get_app_release - env: - GITHUB_TOKEN: ${{ github.token }} - with: - latest: true - draft: false - releaseNameRegEx: '^v[0-9]+\.[0-9]+\.[0-9]+$' - - - name: Replace Strings In Chart - run: | - # Remove prefix '-chart' from tag name - CHART_TAG_NAME=${{ steps.get_chart_release.outputs.tag_name }} - CHART_TAG_NAME=${CHART_TAG_NAME#chart-} - APP_TAG_NAME=${{ steps.get_app_release.outputs.tag_name }} - APP_TAG_NAME=${APP_TAG_NAME#v} - - # Replace strings in charts/nightscaler/Chart.yaml - sed -i "s/appVersion: .*/appVersion: $APP_TAG_NAME/" charts/nightscaler/Chart.yaml - sed -i "s/version: .*/version: $CHART_TAG_NAME/" charts/nightscaler/Chart.yaml - - - name: Install Chart Releaser - run: | - # Get the tar file - curl -L -o chart-releaser.tar.gz https://github.com/helm/chart-releaser/releases/download/v1.6.0/chart-releaser_1.6.0_linux_amd64.tar.gz - # Untar the file - tar -zxvf chart-releaser.tar.gz - # Make executable - chmod +x cr - - name: Package and Upload Chart - env: - GH_TOKEN: ${{ github.token }} - run: | - # Package the chart - ./cr package charts/nightscaler - - # Old upload but doesn't work because of release drafter. 'cr upload' create an release. - # ./cr upload -o BESTSELLER -r nightscaler -p .cr-release-packages --release-name-template ${{ steps.get_chart_release.outputs.tag_name }} --token ${{ secrets.GITHUB_TOKEN }} - - # Create small release-tag - CHART_SEMVER=${{ steps.get_chart_release.outputs.tag_name }} - CHART_SEMVER=${CHART_SEMVER#chart-} - - # Upload the chart to the release - gh release upload ${{ steps.get_chart_release.outputs.tag_name }} ".cr-release-packages/nightscaler-$CHART_SEMVER.tgz" - - name: Update Chart index - run: | - mkdir -p .cr-index - ./cr index -o BESTSELLER -r nightscaler --push --release-name-template ${{ steps.get_chart_release.outputs.tag_name }} --token ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release-drafter-helm.yml b/.github/workflows/release-drafter-helm.yml deleted file mode 100644 index 90e5ead..0000000 --- a/.github/workflows/release-drafter-helm.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: Release Drafter Helm - -on: - push: - # branches to consider in the event; optional, defaults to all - branches: - - master - # pull_request event is required only for autolabeler - pull_request: - # Only following types are handled by the action, but one can default to all as well - types: [opened, reopened, synchronize] - # pull_request_target event is required for autolabeler to support PRs from forks - # pull_request_target: - # types: [opened, reopened, synchronize] - -jobs: - update_release_draft: - permissions: - contents: "write" - pull-requests: "write" - runs-on: ubuntu-latest - steps: - # (Optional) GitHub Enterprise requires GHE_HOST variable set - #- name: Set GHE_HOST - # run: | - # echo "GHE_HOST=${GITHUB_SERVER_URL##https:\/\/}" >> $GITHUB_ENV - - # Drafts your next Release notes as Pull Requests are merged into "master" - - uses: release-drafter/release-drafter@v5 - # (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml - with: - config-name: release-drafter-helm.yml - # disable-autolabeler: true - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/charts/nightscaler/templates/deployment.yaml b/charts/nightscaler/templates/deployment.yaml index 1f7f916..11ce826 100644 --- a/charts/nightscaler/templates/deployment.yaml +++ b/charts/nightscaler/templates/deployment.yaml @@ -32,15 +32,19 @@ spec: env: - name: NIGHTSCALER_PROJECT_ID value: {{ .Values.pubsub.projectId }} - - name: NIGHTSCALER_TOPIC - value: {{ .Values.pubsub.topic }} - - name: NIGHTSCALER_CLUSTERNAME - value: {{ .Values.pubsub.clustername }} + - name: NIGHTSCALER_LISTEN_TOPIC + value: {{ .Values.pubsub.listen_topic }} + - name: NIGHTSCALER_PUBLISH_TOPIC + value: {{ .Values.pubsub.publish_topic }} - name: NIGHTSCALER_TIMEZONE value: {{ .Values.podEnvVars.timezone }} - name: NIGHTSCALER_DEBUG value: "{{ .Values.podEnvVars.debug }}" - name: NIGHTSCALER_JSON_LOGGING value: "{{ .Values.podEnvVars.jsonLogging }}" + {{- if .Values.pubsub.clustername }} + - name: NIGHTSCALER_CLUSTERNAME + value: {{ .Values.pubsub.clustername }} + {{- end }} resources: {{- toYaml .Values.resources | nindent 12 }} diff --git a/charts/nightscaler/values.yaml b/charts/nightscaler/values.yaml index 8bda4d5..ca196c5 100644 --- a/charts/nightscaler/values.yaml +++ b/charts/nightscaler/values.yaml @@ -10,7 +10,10 @@ pubsub: projectId: "" # Pub/Sub topic to subscribe to # REQUIRED - topic: "" + listen_topic: "" + # Pub/Sub topic to publish to + # REQUIRED + publish_topic: "" # Name of the cluster it is running in. Used to identify the cluster in the Pub/Sub message. # REQUIRED clustername: ""