Skip to content

Commit 85e5290

Browse files
committed
Merge branch 'new_deployment' into new_deployment_runs_on
2 parents 48cedc8 + e1ede24 commit 85e5290

File tree

9 files changed

+253
-8
lines changed

9 files changed

+253
-8
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: build-push-helm-chart
2+
description: Build helm chart and push it to ChartMuseum
3+
author: datavisyn
4+
5+
inputs:
6+
chart_repository_url:
7+
description: "Helm chart repository URL where to push the chart"
8+
required: true
9+
chart_repository_username:
10+
description: "Helm chart repository username"
11+
required: true
12+
chart_repository_password:
13+
description: "Helm chart repository password"
14+
required: true
15+
current_directory:
16+
description: "Current directory for building the helm chart"
17+
required: true
18+
runs:
19+
using: "composite"
20+
steps:
21+
- name: Set up helm
22+
uses: azure/setup-helm@v3
23+
with:
24+
version: "v3.12.2"
25+
id: install
26+
- name: Print helm version
27+
run: |
28+
helm version
29+
shell: bash
30+
- name: Install Helm push plugin
31+
run: |
32+
helm plugin install https://github.com/chartmuseum/helm-push
33+
helm push --help
34+
shell: bash
35+
- name: Set up helm chart repository
36+
run: |
37+
helm repo add chartmuseum $CHART_REPOSITORY_URL --username $CHART_REPOSITORY_USERNAME --password $CHART_REPOSITORY_PASSWORD
38+
helm repo list
39+
helm repo update
40+
env:
41+
CHART_REPOSITORY_URL: ${{ inputs.chart_repository_url }}
42+
CHART_REPOSITORY_USERNAME: ${{ inputs.chart_repository_username }}
43+
CHART_REPOSITORY_PASSWORD: ${{ inputs.chart_repository_password }}
44+
shell: bash
45+
- name: Inspect and lint helm chart
46+
run: |
47+
cd $CURRENT_DIRECTORY
48+
helm inspect chart .
49+
helm lint
50+
env:
51+
CURRENT_DIRECTORY: ${{ inputs.current_directory }}
52+
shell: bash
53+
- name: Build and push helm chart
54+
run: |
55+
cd $CURRENT_DIRECTORY
56+
helm dependency update
57+
helm cm-push . chartmuseum
58+
env:
59+
CURRENT_DIRECTORY: ${{ inputs.current_directory }}
60+
shell: bash
61+
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: check-helm-chart-version
2+
description: Check helm chart version and appVersion in Chart.yaml with package.json version
3+
author: datavisyn
4+
5+
inputs:
6+
package_file:
7+
description: "Path to the package.json file"
8+
default: "./package.json"
9+
required: false
10+
chart_directory:
11+
description: "Helm chart directory where to find the Chart.yaml file"
12+
required: true
13+
check_image_tag:
14+
description: "Check if the image tag in values.yaml is equal to the package.json version"
15+
required: false
16+
default: "false"
17+
runs:
18+
using: "composite"
19+
steps:
20+
- name: Check helm chart version
21+
run: |
22+
export CHART_YAML=$CHART_DIRECTORY/Chart.yaml
23+
export CHART_VERSION=$(yq '.version' < $CHART_YAML)
24+
export CHART_APP_VERSION=$(yq '.appVersion' < $CHART_YAML)
25+
export CHART_IMAGE_TAG=$(yq '.imageTag' < $CHART_DIRECTORY/values.yaml)
26+
export PACKAGE_VERSION=$(jq -r '.version' $PACKAGE_FILE)
27+
export SHOULD_EXIT=0
28+
29+
if [[ $CHART_VERSION != $PACKAGE_VERSION ]]; then
30+
echo "Chart version is not equal to package version."
31+
echo "Chart version: $CHART_VERSION"
32+
echo "Package version: $PACKAGE_VERSION"
33+
echo "---"
34+
export SHOULD_EXIT=1
35+
else
36+
echo "Chart version is equal to package version."
37+
echo "Chart version: $CHART_VERSION"
38+
echo "Package version: $PACKAGE_VERSION"
39+
echo "---"
40+
fi
41+
42+
if [[ $CHART_APP_VERSION != $PACKAGE_VERSION ]]; then
43+
echo "Chart appVersion is not equal to package version."
44+
echo "Chart appVersion: $CHART_APP_VERSION"
45+
echo "Package version: $PACKAGE_VERSION"
46+
echo "---"
47+
export SHOULD_EXIT=1
48+
else
49+
echo "Chart appVersion is equal to package version."
50+
echo "Chart appVersion: $CHART_APP_VERSION"
51+
echo "Package version: $PACKAGE_VERSION"
52+
echo "---"
53+
fi
54+
55+
if [[ $CHECK_IMAGE_TAG == "true" ]]; then
56+
echo "Checking imageTag in values.yaml"
57+
if [[ $CHART_IMAGE_TAG != v$PACKAGE_VERSION ]]; then
58+
echo "Chart imageTag is not equal to package version."
59+
echo "Chart imageTag: $CHART_IMAGE_TAG"
60+
echo "Package version: v$PACKAGE_VERSION"
61+
echo "---"
62+
export SHOULD_EXIT=1
63+
else
64+
echo "Chart imageTag is equal to package version."
65+
echo "Chart imageTag: $CHART_IMAGE_TAG"
66+
echo "Package version: v$PACKAGE_VERSION"
67+
echo "---"
68+
fi
69+
fi
70+
71+
if [[ $SHOULD_EXIT == 1 ]]; then
72+
echo "Version mismatch. Please update the version in Chart.yaml and values.yaml to match the version in package.json."
73+
echo "Exiting..."
74+
exit 1
75+
fi
76+
shell: bash
77+
env:
78+
PACKAGE_FILE: ${{ inputs.package_file }}
79+
CHART_DIRECTORY: ${{ inputs.chart_directory }}
80+
CHECK_IMAGE_TAG: ${{ inputs.check_image_tag }}

.github/actions/get-product-parameters/action.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ runs:
8181
stage=develop
8282
if [[ $BRANCH_NAME == main* || $BRANCH_NAME == rc-* || $BRANCH_NAME == v[0-9]* ]] ; then
8383
stage=production
84+
elif [[ $BRANCH_NAME == insight* ]] ; then
85+
stage=insight
8486
fi
8587
# get image tags
8688
build_time=$(TZ=$TIME_ZONE date +%Y-%m-%dT%H%M%SZ)

.github/actions/lint-docker/entrypoint.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
cp /hadolint-matcher.json "$HOME/"
55
# remove matcher during cleanup
66
cleanup() {
7+
# shellcheck disable=SC2317
78
echo "::remove-matcher owner=datavisyn/lint-docker::"
89
}
910
trap cleanup EXIT
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: build-push-helm-chart
2+
3+
on:
4+
workflow_call:
5+
secrets:
6+
DV_CHARTMUSEUM_URL:
7+
required: false
8+
DV_CHARTMUSEUM_USER:
9+
required: true
10+
DV_CHARTMUSEUM_PASSWORD:
11+
required: true
12+
inputs:
13+
current_directory:
14+
description: "Current directory for building the helm chart"
15+
required: true
16+
type: string
17+
chart_repository_url:
18+
description: "Helm chart repository URL where to push the chart"
19+
required: false
20+
type: string
21+
22+
permissions:
23+
id-token: write
24+
contents: read
25+
26+
env:
27+
WORKFLOW_BRANCH: "new_deployment"
28+
29+
concurrency:
30+
group: '${{ github.workflow }}-${{ github.ref || github.head_ref }}'
31+
cancel-in-progress: true
32+
33+
jobs:
34+
build:
35+
concurrency:
36+
group: "${{ github.workflow }}-${{ github.ref || github.head_ref }}-${{ inputs.chart_repository_url }}"
37+
cancel-in-progress: true
38+
runs-on: ubuntu-20.04
39+
steps:
40+
# checkout specific source repository
41+
- uses: actions/checkout@v3
42+
# checkout this workflow repository to get actions
43+
- uses: actions/checkout@v3
44+
with:
45+
repository: datavisyn/github-workflows
46+
ref: ${{ env.WORKFLOW_BRANCH }}
47+
path: ./tmp/github-workflows
48+
- uses: ./tmp/github-workflows/.github/actions/build-push-helm-chart
49+
with:
50+
chart_repository_url: ${{ inputs.chart_repository_url || secrets.DV_CHARTMUSEUM_URL }}
51+
chart_repository_username: ${{ secrets.DV_CHARTMUSEUM_USER }}
52+
chart_repository_password: ${{ secrets.DV_CHARTMUSEUM_PASSWORD }}
53+
current_directory: ${{ inputs.current_directory }}

.github/workflows/build-single-product-part.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ jobs:
178178
stage_str=".dev"
179179
if [[ $STAGE == "production" ]]; then
180180
stage_str=".prod"
181+
elif [[ $STAGE == "insight" ]]; then
182+
stage_str=".insight"
181183
fi
182184
echo "$stage_str"
183185
if [[ -f "$COMPONENT_DIRECTORY/.env" ]]; then

.github/workflows/build-workspace-product-part.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -193,18 +193,18 @@ jobs:
193193
194194
if [[ $product_version == *"SNAPSHOT"* ]]; then
195195
echo "replace SNAPSHOT in version with timestamp"
196-
product_version=$(echo "$product_version" | sed "s/SNAPSHOT/$(date +%Y%m%d-%H%M%S)/g")
196+
product_version="${product_version//SNAPSHOT/$(date +%Y%m%d-%H%M%S)}"
197197
echo "product_version=$product_version"
198198
fi
199199
200-
workspace_version=$(jq -rc '.version' ./tmp/$COMPONENT/package.json)
200+
workspace_version=$(jq -rc '.version' "./tmp/$COMPONENT/package.json")
201201
echo "workspace_version=$workspace_version"
202202
203-
if [[ $product_version != $workspace_version ]]; then
203+
if [[ "$product_version" != "$workspace_version" ]]; then
204204
echo "update workspace version"
205-
jq --arg version "$product_version" '.version = $version' ./tmp/$COMPONENT/package.json > ./tmp/$COMPONENT/package.json.tmp
206-
mv ./tmp/$COMPONENT/package.json.tmp ./tmp/$COMPONENT/package.json
207-
echo "workspace version updated to $(jq -rc '.version' ./tmp/$COMPONENT/package.json)"
205+
jq --arg version "$product_version" '.version = $version' "./tmp/$COMPONENT/package.json" > "./tmp/$COMPONENT/package.json.tmp"
206+
mv "./tmp/$COMPONENT/package.json.tmp" "./tmp/$COMPONENT/package.json"
207+
echo "workspace version updated to $(jq -rc '.version' './tmp/$COMPONENT/package.json')"
208208
fi
209209
env:
210210
COMPONENT: ${{ inputs.component }}
@@ -225,8 +225,10 @@ jobs:
225225
if: ${{ steps.get-parameters.outputs.type == 'web' }}
226226
run: |
227227
stage_str=".dev"
228-
if [[ $STAGE == "production" ]]; then
228+
if [[ "$STAGE" == "production" ]]; then
229229
stage_str=".prod"
230+
elif [[ "$STAGE" == "insight" ]]; then
231+
stage_str=".insight"
230232
fi
231233
echo "$stage_str"
232234
if [[ -f "$COMPONENT_DIRECTORY/.env" ]]; then
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: check-helm-chart-version
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
package_file:
7+
description: "Path to the package.json file"
8+
default: "./package.json"
9+
type: string
10+
required: false
11+
chart_directory:
12+
description: "Helm chart directory where to find the Chart.yaml file"
13+
type: string
14+
required: true
15+
check_image_tag:
16+
description: "Check if the image tag in values.yaml is equal to the package.json version"
17+
default: false
18+
type: boolean
19+
required: false
20+
21+
permissions:
22+
id-token: write
23+
contents: read
24+
25+
env:
26+
WORKFLOW_BRANCH: "new_deployment"
27+
28+
jobs:
29+
check-helm-chart-version:
30+
runs-on: ubuntu-20.04
31+
steps:
32+
# checkout specific source repository
33+
- uses: actions/checkout@v3
34+
# checkout this workflow repository to get actions
35+
- uses: actions/checkout@v3
36+
with:
37+
repository: datavisyn/github-workflows
38+
ref: ${{ env.WORKFLOW_BRANCH }}
39+
path: ./tmp/github-workflows
40+
- uses: ./tmp/github-workflows/.github/actions/check-helm-chart-version
41+
with:
42+
package_file: ${{ inputs.package_file }}
43+
chart_directory: ${{ inputs.chart_directory }}
44+
check_image_tag: ${{ inputs.check_image_tag }}

.github/workflows/deploy-product.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ on:
2020

2121
inputs:
2222
stage:
23-
description: "stage that should be deployed (develop|qa|production)"
23+
description: "stage that should be deployed (develop|qa|production|insight)"
2424
required: true
2525
type: string
2626
customer:

0 commit comments

Comments
 (0)