Skip to content

Commit c909b96

Browse files
wchomiksdomarecki-sapsk31337
authored
Innitial OpenSourcing blueprint-building-blocks (#6)
--------- Co-authored-by: Sebastian Domarecki <[email protected]> Co-authored-by: Steffen <[email protected]>
1 parent b3405a7 commit c909b96

File tree

287 files changed

+11783
-3
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

287 files changed

+11783
-3
lines changed

.github/.yamllint.config.yaml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
# Default configuration https://yamllint.readthedocs.io/en/stable/configuration.html
3+
yaml-files:
4+
- '*.yaml'
5+
- '*.yml'
6+
- '.yamllint'
7+
8+
rules:
9+
anchors: enable
10+
braces: enable
11+
brackets: enable
12+
colons: enable
13+
commas: enable
14+
comments:
15+
level: warning
16+
min-spaces-from-content: 1
17+
comments-indentation:
18+
level: warning
19+
document-end: disable
20+
document-start:
21+
level: warning
22+
empty-lines: enable
23+
empty-values: #disable
24+
forbid-in-block-mappings: true
25+
forbid-in-flow-mappings: true
26+
float-values: disable
27+
hyphens: enable
28+
indentation: #enable
29+
spaces: consistent
30+
indent-sequences: whatever
31+
check-multi-line-strings: false
32+
key-duplicates: enable
33+
key-ordering: disable
34+
line-length: disable
35+
new-line-at-end-of-file: enable
36+
new-lines: enable
37+
octal-values: disable
38+
quoted-strings: disable
39+
# quote-type: double
40+
# required: true
41+
# extra-required: []
42+
# extra-allowed: []
43+
# allow-quoted-quotes: false
44+
trailing-spaces: enable
45+
truthy:
46+
level: warning
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
name: Bug Report
3+
about: Report a bug
4+
labels: kind/bug
5+
6+
---
7+
8+
**What happened**:
9+
10+
**What you expected to happen**:
11+
12+
**How to reproduce it (as minimally and precisely as possible)**:
13+
14+
**Anything else we need to know**:
15+
16+
**Environment**:
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
name: Enhancement Request
3+
about: Suggest an enhancement
4+
labels: kind/enhancement
5+
6+
---
7+
8+
**What would you like to be added**:
9+
10+
**Why is this needed**:
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: "Helm Chart Release Tag"
2+
description: "Generates release notes and creates a new GitHub release for a Helm Chart tag"
3+
4+
runs:
5+
using: "composite"
6+
steps:
7+
- name: Checkout
8+
uses: actions/checkout@v4
9+
with:
10+
fetch-depth: 0
11+
- name: Print commit SHA
12+
shell: bash
13+
run: echo ${{ github.sha }}
14+
- name: Tag modified Helm Chart
15+
shell: bash
16+
run: |
17+
set +e
18+
${GITHUB_ACTION_PATH}/git-release-fix.sh &> ${GITHUB_WORKSPACE}/bash_output.txt
19+
env:
20+
COMMIT_HASH: ${{ github.sha }}
21+
22+
- name: Bash Output
23+
shell: bash
24+
if: always()
25+
run: |
26+
if [ -f "${GITHUB_WORKSPACE}/bash_output.txt" ]; then
27+
echo "::group:: Bash Script Output"
28+
cat ${GITHUB_WORKSPACE}/bash_output.txt
29+
echo "::endgroup::"
30+
fi
31+
32+
if [ -f "${GITHUB_WORKSPACE}/pr-status-check-human-friendly.txt" ]; then
33+
echo "::group:: PR Status Check Human Friendly Output"
34+
cat "${GITHUB_WORKSPACE}/pr-status-check-human-friendly.txt"
35+
echo "::endgroup::"
36+
fi
37+
38+
if [ -f "${GITHUB_WORKSPACE}/github-workflow-commands.txt" ]; then
39+
cat "${GITHUB_WORKSPACE}/github-workflow-commands.txt"
40+
fi
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/bash
2+
###################################################################
3+
# Script Name : github release create
4+
# Description : This script fetches all Git tags, checks if a GitHub release already exists for
5+
# each tag, and if not, generates release notes and creates a new GitHub release
6+
# for the tag. It searches for a previous tag that starts with the same name as the
7+
# current tag but has a lower semantic version.
8+
# Args : -
9+
# Hint : This script is not meant for any pipeline just for cleanup!
10+
###################################################################
11+
set +e
12+
13+
# Fetch all tags from the remote
14+
gh auth status
15+
16+
git fetch --tags
17+
18+
# Get all tags
19+
tags=$(git tag)
20+
21+
# Fetch all existing releases
22+
existing_releases=$(gh release list --limit 99999 --json tagName --jq '.[].tagName')
23+
24+
# Loop through each tag
25+
for tag in $tags; do
26+
if echo "$existing_releases" | grep -q "^$tag$"; then
27+
echo "Release for tag $tag already exists. Skipping..."
28+
continue
29+
fi
30+
31+
# Find the previous tag with the same prefix but lower semantic version
32+
previous_tag=""
33+
prefix=""
34+
prefix=$(echo "$tag" | sed -E 's/([0-9]+\.[0-9]+\.[0-9]+)$//')
35+
previous_tag=$(git tag -l "${prefix}*" | sort -V | grep -B1 "$tag" | head -n 1)
36+
37+
release_notes=""
38+
# Generate release notes using the GitHub CLI
39+
if [ -n "$previous_tag" ] && [ "$previous_tag" != "$tag" ]; then
40+
release_notes=$(gh api repos/:owner/:repo/releases/generate-notes -f tag_name="$tag" -f previous_tag_name="$previous_tag" -q '.body')
41+
printf 'tag: %s != previous_tag: %s \n %s' "$tag" "$previous_tag" "$release_notes"
42+
else
43+
release_notes=$(gh api repos/:owner/:repo/releases/generate-notes -f tag_name="$tag" -q '.body')
44+
printf 'tag: %s == previous_tag: %s \n %s' "$tag" "$previous_tag" "$release_notes"
45+
fi
46+
47+
# Create a release for each tag
48+
gh release create "$tag" --title "$tag" --notes "$release_notes" --verify-tag --latest=false
49+
50+
done
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: 'Tag modified Helm Chart'
2+
description: 'Create Git Tag for every modified Helm Chart'
3+
4+
runs:
5+
using: "composite"
6+
steps:
7+
- name: Checkout
8+
uses: actions/checkout@v4
9+
with:
10+
fetch-depth: 0
11+
- name: Print commit SHA
12+
shell: bash
13+
run: echo ${{ github.sha }}
14+
- name: Tag modified Helm Chart
15+
shell: bash
16+
run: |
17+
set +e
18+
${GITHUB_ACTION_PATH}/git-tag-modified-helm-chart.sh &> ${GITHUB_WORKSPACE}/bash_output.txt
19+
env:
20+
COMMIT_HASH: ${{ github.sha }}
21+
22+
- name: Bash Output
23+
shell: bash
24+
if: always()
25+
run: |
26+
if [ -f "${GITHUB_WORKSPACE}/bash_output.txt" ]; then
27+
echo "::group:: Bash Script Output"
28+
cat ${GITHUB_WORKSPACE}/bash_output.txt
29+
echo "::endgroup::"
30+
fi
31+
32+
if [ -f "${GITHUB_WORKSPACE}/pr-status-check-human-friendly.txt" ]; then
33+
echo "::group:: PR Status Check Human Friendly Output"
34+
cat "${GITHUB_WORKSPACE}/pr-status-check-human-friendly.txt"
35+
echo "::endgroup::"
36+
fi
37+
38+
if [ -f "${GITHUB_WORKSPACE}/github-workflow-commands.txt" ]; then
39+
cat "${GITHUB_WORKSPACE}/github-workflow-commands.txt"
40+
fi
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
#!/bin/bash
2+
###################################################################
3+
#Script Name : git tag modified helm chart
4+
#Description : creates a git tag for each modified helm chart
5+
#Args : -
6+
#Hint : Only works with Helm Chart Version compare
7+
###################################################################
8+
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
9+
# shellcheck disable=SC1091
10+
source "$SCRIPT_DIR"/../shared-variables.sh
11+
12+
declare resultPwd exitCode
13+
14+
set +e
15+
echo "The script you are running has:"
16+
echo "basename: [$(basename "$0")]"
17+
echo "dirname : [$(dirname "$0")]"
18+
echo "pwd : [$(pwd)]"
19+
20+
declare -a filesToRemove=("pr-status-check-human-friendly.txt" "modified_files.txt")
21+
REMOVE_FILES_IF_EXISTS "$resultPwd" "${filesToRemove[@]}"
22+
###################################################################
23+
if [ -z "$COMMIT_HASH" ]; then
24+
COMMIT_HASH="89b624080bb62e7f5ac340d81fef96c9d6446d22"
25+
echo "!!! WARNING: \$COMMIT_HASH NEEDS TO BE SET e.g. Default set COMMIT_HASH=${COMMIT_HASH}! \"export COMMIT_HASH=${COMMIT_HASH}\"!!!"
26+
exit 1
27+
fi
28+
29+
30+
###################################################################
31+
# Function to print a row with fixed-width columns
32+
print_row() {
33+
printf "%-70s %-50s %-15s %-15s\n" "$1" "$2" "$3" "$4"
34+
}
35+
36+
git_tag_check() {
37+
local tag=$1
38+
git rev-parse -q --verify "refs/tags/$tag" &>/dev/null
39+
}
40+
###################################################################
41+
42+
# List modified files of commit
43+
git diff-tree --no-commit-id --name-only -r "$COMMIT_HASH" >modified_files.txt
44+
# shellcheck disable=SC2181
45+
if [ $? != 0 ]; then
46+
exit 1
47+
fi
48+
# Iterate over the array of paths with filenames and extract the directory paths
49+
unique_paths=()
50+
while IFS= read -r path; do
51+
52+
dir=$(dirname "$path")
53+
54+
if [[ "$dir" == *templates ]]; then
55+
dir=${dir%/*}
56+
fi
57+
dir=${dir%*/templates*} # retain the part before "/templates"
58+
59+
if [ -f "$dir/Chart.yaml" ] || [ -f "$dir/Chart.yml" ]; then
60+
unique_paths+=("$dir")
61+
fi
62+
done <"modified_files.txt"
63+
64+
if [ ${#unique_paths[@]} -eq 0 ]; then
65+
echo -e "No Helm Charts have been modified!\n"
66+
echo -e "List of Modified files:"
67+
cat "modified_files.txt"
68+
exit "$exitCode"
69+
fi
70+
71+
# Sort and remove duplicates from the list of paths
72+
# shellcheck disable=SC2207
73+
unique_paths=($(echo "${unique_paths[@]}" | tr ' ' '\n' | sort -u))
74+
{
75+
# Header row
76+
printf "%-70s %-50s %-15s %-15s\n" "Modified Helm Chart:" "Name:" "Version:" "Status:"
77+
78+
git checkout "$COMMIT_HASH"
79+
80+
for helmChart in "${unique_paths[@]}"; do
81+
chartVersion=$(yq -r eval '.version' "$helmChart/Chart.yaml")
82+
chartName=$(yq -r eval '.name' "$helmChart/Chart.yaml")
83+
gitTag="$chartName-$chartVersion"
84+
if git_tag_check "$gitTag"; then
85+
print_row "$helmChart" "$chartName" "$chartVersion" "-"
86+
else
87+
88+
git tag "$gitTag" "$COMMIT_HASH"
89+
# shellcheck disable=SC2181
90+
if [ $? != 0 ]; then
91+
print_row "$helmChart" "$chartName" "$chartVersion" "ERROR: git tag $gitTag"
92+
exit 1
93+
fi
94+
95+
git push origin "$gitTag"
96+
# shellcheck disable=SC2181
97+
if [ $? != 0 ]; then
98+
print_row "$helmChart" "$chartName" "$chartVersion" "ERROR: git push origin $gitTag"
99+
exit 1
100+
fi
101+
102+
print_row "$helmChart" "$chartName" "$chartVersion" "git tagged&pushed $gitTag"
103+
104+
fi
105+
106+
done
107+
108+
} >>"$resultPwd/pr-status-check-human-friendly.txt"
109+
110+
cat "$resultPwd/pr-status-check-human-friendly.txt"
111+
112+
exit "$exitCode"
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/bash
2+
###################################################################
3+
#Script Name :
4+
#Description :
5+
#Args : -
6+
#Hint :
7+
###################################################################
8+
set -e
9+
resultPwd=$(pwd)
10+
helmChartListingFileName="helm-charts-templated.yaml"
11+
emptyManifestString="WARNING: This chart is deprecated"
12+
newLineString="-------------------------------------------------------------------------------------------------------------------------"
13+
msgHelpStart=""
14+
#msgEverythingIsFine="/人◕ __ ◕人\ Everything seems to be all right (⌐⊙_⊙)"
15+
msgEverythingIsFine="☺ √"
16+
exitCode=0
17+
# Define color escape codes
18+
RED='\033[0;31m'
19+
GREEN='\033[0;32m'
20+
YELLOW='\033[0;33m'
21+
BLUE='\033[0;34m'
22+
BOLD='\033[1m'
23+
UNDERLINE='\033[4m'
24+
REVERSE='\033[7m'
25+
RESET='\033[0m' # Reset color
26+
###################################################################
27+
declare -a filesToRemove=("pr-status-check-human-friendly.txt" "github-workflow-commands.txt")
28+
###################################################################
29+
function REMOVE_FILES_IF_EXISTS {
30+
arr=("$@")
31+
for fileToRemove in "${arr[@]}"
32+
do
33+
if [ -f "$1/$fileToRemove" ]; then
34+
rm "$1/$fileToRemove"
35+
#echo "removed $1/$fileToRemove"
36+
fi
37+
done
38+
}
39+
function ASSERT_FILE_EXISTS_WITH_MSG {
40+
if [ ! -f "$1/$2" ]; then
41+
echo "!! ERROR missing file $1/$2 !!$3"
42+
exit 1
43+
fi
44+
}
45+
###################################################################
46+
if [ -n "$GITHUB_WORKSPACE" ]; then
47+
cd "$GITHUB_WORKSPACE" || exit
48+
resultPwd=$GITHUB_WORKSPACE
49+
fi
50+
REMOVE_FILES_IF_EXISTS "$resultPwd" "${filesToRemove[@]}"
51+
###################################################################
52+
export helmChartListingFileName emptyManifestString newLineString exitCode resultPwd helmChartListTemplatedManifestsFileName msgHelpStart msgEverythingIsFine RED GREEN YELLOW BLUE BOLD UNDERLINE RESET REVERSE

0 commit comments

Comments
 (0)