Fix CircleCI config (#804)

* Fix CircleCI config

* Add manual trigger option
This commit is contained in:
Tom Proctor 2022-10-27 11:37:38 +01:00 committed by GitHub
parent 5d7014c7bb
commit 46e6fb5ad1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5,14 +5,17 @@ orbs:
jobs: jobs:
update-helm-charts-index: update-helm-charts-index:
docker: docker:
- image: docker.mirror.hashicorp.services/circleci/golang:1.19.2 - image: docker.mirror.hashicorp.services/cimg/go:1.19.2
steps: steps:
- checkout - checkout
- run: - run:
name: verify Chart version matches tag version name: verify Chart version matches tag version
environment:
RELEASE_TAG: << pipeline.parameters.release-tag >>
command: | command: |
GO111MODULE=on go get github.com/mikefarah/yq/v2 go install github.com/mikefarah/yq/v2@latest
git_tag=$(echo "${CIRCLE_TAG#v}") export TAG=${RELEASE_TAG:-$CIRCLE_TAG}
git_tag=$(echo "${TAG#v}")
chart_tag=$(yq r Chart.yaml version) chart_tag=$(yq r Chart.yaml version)
if [ "${git_tag}" != "${chart_tag}" ]; then if [ "${git_tag}" != "${chart_tag}" ]; then
echo "chart version (${chart_tag}) did not match git version (${git_tag})" echo "chart version (${chart_tag}) did not match git version (${git_tag})"
@ -20,17 +23,25 @@ jobs:
fi fi
- run: - run:
name: update helm-charts index name: update helm-charts index
environment:
RELEASE_TAG: << pipeline.parameters.release-tag >>
command: | command: |
curl --show-error --silent --fail --user "${CIRCLE_TOKEN}:" \ curl --show-error --silent --fail --user "${CIRCLE_TOKEN}:" \
-X POST \ -X POST \
-H 'Content-Type: application/json' \ -H 'Content-Type: application/json' \
-H 'Accept: application/json' \ -H 'Accept: application/json' \
-d "{\"branch\": \"main\",\"parameters\":{\"SOURCE_REPO\": \"${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}\",\"SOURCE_TAG\": \"${CIRCLE_TAG}\"}}" \ -d "{\"branch\": \"main\",\"parameters\":{\"SOURCE_REPO\": \"${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}\",\"SOURCE_TAG\": \"${RELEASE_TAG:-$CIRCLE_TAG}\"}}" \
"${CIRCLE_ENDPOINT}/${CIRCLE_PROJECT}/pipeline" "${CIRCLE_ENDPOINT}/${CIRCLE_PROJECT}/pipeline"
- slack/status: - slack/status:
fail_only: true fail_only: true
failure_message: "Failed to trigger an update to the helm charts index. Check the logs at: ${CIRCLE_BUILD_URL}" failure_message: "Failed to trigger an update to the helm charts index. Check the logs at: ${CIRCLE_BUILD_URL}"
parameters:
release-tag:
type: string
default: ""
description: "The tag to release, including v, e.g. v0.22.1"
workflows: workflows:
version: 2 version: 2
# Note: unit and acceptance tests are now being run in GitHub Actions # Note: unit and acceptance tests are now being run in GitHub Actions
@ -43,3 +54,8 @@ workflows:
only: /^v.*/ only: /^v.*/
branches: branches:
ignore: /.*/ ignore: /.*/
manual-trigger-update-helm-charts-index:
when: << pipeline.parameters.release-tag >>
jobs:
- update-helm-charts-index:
context: helm-charts-trigger-vault