feat: improve formatting, revert yq strip command
All checks were successful
renovate / renovate (push) Successful in 1m26s
All checks were successful
renovate / renovate (push) Successful in 1m26s
This commit is contained in:
@@ -80,18 +80,15 @@ jobs:
|
|||||||
DIFF_TARGET=""
|
DIFF_TARGET=""
|
||||||
|
|
||||||
if [[ "${{ github.event_name }}" == "schedule" || "${{ github.event_name }}" == "workflow_dispatch" ]]; then
|
if [[ "${{ github.event_name }}" == "schedule" || "${{ github.event_name }}" == "workflow_dispatch" ]]; then
|
||||||
echo ""
|
|
||||||
echo ">> Mode: Dispatch/Schedule (Render All)"
|
echo ">> Mode: Dispatch/Schedule (Render All)"
|
||||||
RENDER_ALL="true"
|
RENDER_ALL="true"
|
||||||
|
|
||||||
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
|
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
|
||||||
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'automerge') }}" == "true" ]]; then
|
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'automerge') }}" == "true" ]]; then
|
||||||
echo ""
|
|
||||||
echo ">> Mode: PR Merged (Automerge)"
|
echo ">> Mode: PR Merged (Automerge)"
|
||||||
IS_AUTOMERGE="true"
|
IS_AUTOMERGE="true"
|
||||||
|
|
||||||
else
|
else
|
||||||
echo ""
|
|
||||||
echo ">> Mode: PR Merged (Standard)"
|
echo ">> Mode: PR Merged (Standard)"
|
||||||
|
|
||||||
fi
|
fi
|
||||||
@@ -99,12 +96,12 @@ jobs:
|
|||||||
DIFF_TARGET="HEAD^..HEAD"
|
DIFF_TARGET="HEAD^..HEAD"
|
||||||
|
|
||||||
elif [[ "${{ github.event_name }}" == "push" ]]; then
|
elif [[ "${{ github.event_name }}" == "push" ]]; then
|
||||||
echo ""
|
|
||||||
echo ">> Mode: Push (Standard)"
|
echo ">> Mode: Push (Standard)"
|
||||||
DIFF_TARGET="${{ github.event.before }}..HEAD"
|
DIFF_TARGET="${{ github.event.before }}..HEAD"
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
echo "----"
|
echo "----"
|
||||||
|
|
||||||
echo "is_automerge=${IS_AUTOMERGE}" >> "$GITHUB_OUTPUT"
|
echo "is_automerge=${IS_AUTOMERGE}" >> "$GITHUB_OUTPUT"
|
||||||
@@ -118,7 +115,6 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
cd "${MANIFEST_DIR}"
|
cd "${MANIFEST_DIR}"
|
||||||
|
|
||||||
echo ""
|
|
||||||
echo ">> Configure git to use gitea-bot as user ..."
|
echo ">> Configure git to use gitea-bot as user ..."
|
||||||
git config user.name "gitea-bot"
|
git config user.name "gitea-bot"
|
||||||
git config user.email "gitea-bot@alexlebens.net"
|
git config user.email "gitea-bot@alexlebens.net"
|
||||||
@@ -149,6 +145,7 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
echo "----"
|
echo "----"
|
||||||
|
|
||||||
echo "BRANCH_NAME=${BRANCH_NAME}" >> "$GITHUB_OUTPUT"
|
echo "BRANCH_NAME=${BRANCH_NAME}" >> "$GITHUB_OUTPUT"
|
||||||
@@ -162,12 +159,10 @@ jobs:
|
|||||||
cd "${MAIN_DIR}"
|
cd "${MAIN_DIR}"
|
||||||
|
|
||||||
if [[ "$RENDER_ALL" == "true" ]]; then
|
if [[ "$RENDER_ALL" == "true" ]]; then
|
||||||
echo ""
|
|
||||||
echo ">> Triggered on dispatch, will check all paths ..."
|
echo ">> Triggered on dispatch, will check all paths ..."
|
||||||
RENDER_DIR=$(find "clusters/${CLUSTER}/helm" -mindepth 1 -maxdepth 1 -type d -exec basename {} \; | sort -u)
|
RENDER_DIR=$(find "clusters/${CLUSTER}/helm" -mindepth 1 -maxdepth 1 -type d -exec basename {} \; | sort -u)
|
||||||
|
|
||||||
else
|
else
|
||||||
echo ""
|
|
||||||
echo ">> Checking for changes from ${DIFF_TARGET} ..."
|
echo ">> Checking for changes from ${DIFF_TARGET} ..."
|
||||||
RENDER_DIR=$(git diff --name-only "${DIFF_TARGET}" | grep -E "^clusters/${CLUSTER}/helm/" | awk -F '/' '{print $4}' | sort -u || true)
|
RENDER_DIR=$(git diff --name-only "${DIFF_TARGET}" | grep -E "^clusters/${CLUSTER}/helm/" | awk -F '/' '{print $4}' | sort -u || true)
|
||||||
|
|
||||||
@@ -176,6 +171,7 @@ jobs:
|
|||||||
if [ -n "${RENDER_DIR}" ]; then
|
if [ -n "${RENDER_DIR}" ]; then
|
||||||
echo ""
|
echo ""
|
||||||
echo ">> Directories to Render:"
|
echo ">> Directories to Render:"
|
||||||
|
echo ""
|
||||||
echo "${RENDER_DIR}"
|
echo "${RENDER_DIR}"
|
||||||
|
|
||||||
echo "----"
|
echo "----"
|
||||||
@@ -190,6 +186,7 @@ jobs:
|
|||||||
echo ""
|
echo ""
|
||||||
echo ">> No chart changes detected"
|
echo ">> No chart changes detected"
|
||||||
|
|
||||||
|
echo ""
|
||||||
echo "----"
|
echo "----"
|
||||||
|
|
||||||
echo "changes-detected=false" >> "$GITHUB_OUTPUT"
|
echo "changes-detected=false" >> "$GITHUB_OUTPUT"
|
||||||
@@ -203,18 +200,15 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
cd "${MAIN_DIR}"
|
cd "${MAIN_DIR}"
|
||||||
|
|
||||||
echo ""
|
|
||||||
echo ">> Adding repositories for chart dependencies ..."
|
echo ">> Adding repositories for chart dependencies ..."
|
||||||
|
echo ""
|
||||||
|
|
||||||
for DIR in ${RENDER_DIR}; do
|
for DIR in ${RENDER_DIR}; do
|
||||||
helm dependency list --max-col-width 120 "${MAIN_DIR}/clusters/${CLUSTER}/helm/${DIR}" 2> /dev/null \
|
helm dependency list --max-col-width 120 "${MAIN_DIR}/clusters/${CLUSTER}/helm/${DIR}" 2> /dev/null \
|
||||||
| tail -n +2 \
|
| tail -n +2 \
|
||||||
| awk 'NF > 0 { print $1, $3 }' \
|
| awk 'NF > 0 { print $1, $3 }' \
|
||||||
| while read -r REPO_NAME REPO_URL; do
|
| while read -r REPO_NAME REPO_URL; do
|
||||||
if [[ "${REPO_URL}" == oci://* ]]; then
|
if [[ -n "${REPO_NAME}" && -n "${REPO_URL}" ]]; then
|
||||||
echo ">> Ignoring OCI repo: ${REPO_URL}"
|
|
||||||
|
|
||||||
elif [[ -n "${REPO_NAME}" && -n "${REPO_URL}" ]]; then
|
|
||||||
helm repo add "${REPO_NAME}" "${REPO_URL}"
|
helm repo add "${REPO_NAME}" "${REPO_URL}"
|
||||||
|
|
||||||
fi
|
fi
|
||||||
@@ -229,6 +223,7 @@ jobs:
|
|||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
echo "----"
|
echo "----"
|
||||||
|
|
||||||
- name: Remove Changed Manifest Files
|
- name: Remove Changed Manifest Files
|
||||||
@@ -238,18 +233,17 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
cd "${MANIFEST_DIR}"
|
cd "${MANIFEST_DIR}"
|
||||||
|
|
||||||
echo ""
|
|
||||||
echo ">> Remove manifest files and rebuild from source ..."
|
echo ">> Remove manifest files and rebuild from source ..."
|
||||||
|
|
||||||
for DIR in ${RENDER_DIR}; do
|
for DIR in ${RENDER_DIR}; do
|
||||||
CHART_PATH="${MANIFEST_DIR}/clusters/${CLUSTER}/manifests/${DIR}"
|
CHART_PATH="${MANIFEST_DIR}/clusters/${CLUSTER}/manifests/${DIR}"
|
||||||
|
|
||||||
echo ""
|
|
||||||
echo "${CHART_PATH}"
|
echo "${CHART_PATH}"
|
||||||
rm -rf "${CHART_PATH}"/*
|
rm -rf "${CHART_PATH}"/*
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
|
echo ""
|
||||||
echo "----"
|
echo "----"
|
||||||
|
|
||||||
- name: Render Helm Manifests
|
- name: Render Helm Manifests
|
||||||
@@ -260,7 +254,6 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
cd "${MAIN_DIR}"
|
cd "${MAIN_DIR}"
|
||||||
|
|
||||||
echo ""
|
|
||||||
echo ">> Rendering Manifests ..."
|
echo ">> Rendering Manifests ..."
|
||||||
|
|
||||||
render_chart() {
|
render_chart() {
|
||||||
@@ -306,10 +299,10 @@ jobs:
|
|||||||
echo "${TEMPLATE}" | yq '... comments=""' | yq 'select(. != null)' | yq -s '"'"${OUTPUT_FOLDER}"'" + .kind + "-" + .metadata.name + ".yaml"'
|
echo "${TEMPLATE}" | yq '... comments=""' | yq 'select(. != null)' | yq -s '"'"${OUTPUT_FOLDER}"'" + .kind + "-" + .metadata.name + ".yaml"'
|
||||||
|
|
||||||
# Strip comments again to ensure formatting correctness
|
# Strip comments again to ensure formatting correctness
|
||||||
if ls "${OUTPUT_FOLDER}"*.yaml 1> /dev/null 2>&1; then
|
for file in "$OUTPUT_FOLDER"/*; do
|
||||||
yq -i '... comments=""' "${OUTPUT_FOLDER}"*.yaml
|
yq -i '... comments=""' $file
|
||||||
|
|
||||||
fi
|
done
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo ">> Manifests for ${CHART_NAME} rendered successfully."
|
echo ">> Manifests for ${CHART_NAME} rendered successfully."
|
||||||
@@ -329,8 +322,9 @@ jobs:
|
|||||||
for DIR in ${RENDER_DIR}; do
|
for DIR in ${RENDER_DIR}; do
|
||||||
echo "${DIR}"
|
echo "${DIR}"
|
||||||
|
|
||||||
done | xargs -n 1 -P 4 -I {} bash -c 'render_chart "$@"' _ {}
|
done | xargs -P 4 -I {} bash -c 'render_chart "$@"' _ {}
|
||||||
|
|
||||||
|
echo ""
|
||||||
echo "----"
|
echo "----"
|
||||||
|
|
||||||
- name: Check for Changes
|
- name: Check for Changes
|
||||||
@@ -342,18 +336,18 @@ jobs:
|
|||||||
GIT_CHANGES=$(git status --porcelain)
|
GIT_CHANGES=$(git status --porcelain)
|
||||||
|
|
||||||
if [ -n "${GIT_CHANGES}" ]; then
|
if [ -n "${GIT_CHANGES}" ]; then
|
||||||
echo ""
|
|
||||||
echo ">> Changes detected"
|
echo ">> Changes detected"
|
||||||
git status --porcelain
|
git status --porcelain
|
||||||
|
|
||||||
|
echo ""
|
||||||
echo "----"
|
echo "----"
|
||||||
|
|
||||||
echo "changes-detected=true" >> "$GITHUB_OUTPUT"
|
echo "changes-detected=true" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
else
|
else
|
||||||
echo ""
|
|
||||||
echo ">> No changes detected, skipping PR creation"
|
echo ">> No changes detected, skipping PR creation"
|
||||||
|
|
||||||
|
echo ""
|
||||||
echo "----"
|
echo "----"
|
||||||
|
|
||||||
fi
|
fi
|
||||||
@@ -374,7 +368,6 @@ jobs:
|
|||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo ""
|
|
||||||
echo ">> Commiting changes to ${BRANCH_NAME} ..."
|
echo ">> Commiting changes to ${BRANCH_NAME} ..."
|
||||||
git add .
|
git add .
|
||||||
git commit -m "${MSG}"
|
git commit -m "${MSG}"
|
||||||
@@ -386,6 +379,7 @@ jobs:
|
|||||||
|
|
||||||
git push -u "https://oauth2:${{ secrets.BOT_TOKEN }}@${REPO_URL#*://}" "${BRANCH_NAME}"
|
git push -u "https://oauth2:${{ secrets.BOT_TOKEN }}@${REPO_URL#*://}" "${BRANCH_NAME}"
|
||||||
|
|
||||||
|
echo ""
|
||||||
echo "----"
|
echo "----"
|
||||||
|
|
||||||
echo "push=true" >> "$GITHUB_OUTPUT"
|
echo "push=true" >> "$GITHUB_OUTPUT"
|
||||||
@@ -403,7 +397,6 @@ jobs:
|
|||||||
|
|
||||||
API_ENDPOINT="${GITEA_URL}/api/v1/repos/${{ gitea.repository }}/pulls?base_branch=${BASE_BRANCH}&state=open&page=1"
|
API_ENDPOINT="${GITEA_URL}/api/v1/repos/${{ gitea.repository }}/pulls?base_branch=${BASE_BRANCH}&state=open&page=1"
|
||||||
|
|
||||||
echo ""
|
|
||||||
echo ">> Checking if PR from branch ${HEAD_BRANCH} into ${BASE_BRANCH}"
|
echo ">> Checking if PR from branch ${HEAD_BRANCH} into ${BASE_BRANCH}"
|
||||||
echo ">> With Endpoint of:"
|
echo ">> With Endpoint of:"
|
||||||
echo "$API_ENDPOINT"
|
echo "$API_ENDPOINT"
|
||||||
@@ -414,6 +407,7 @@ jobs:
|
|||||||
echo ""
|
echo ""
|
||||||
echo ">> Pull Request has been found open, will update"
|
echo ">> Pull Request has been found open, will update"
|
||||||
|
|
||||||
|
echo ""
|
||||||
echo "----"
|
echo "----"
|
||||||
|
|
||||||
echo "pull-request-exists=$(cat response_body.json | jq -r .[0].number)" >> "$GITHUB_OUTPUT"
|
echo "pull-request-exists=$(cat response_body.json | jq -r .[0].number)" >> "$GITHUB_OUTPUT"
|
||||||
@@ -423,6 +417,7 @@ jobs:
|
|||||||
echo ""
|
echo ""
|
||||||
echo ">> Pull Request not found"
|
echo ">> Pull Request not found"
|
||||||
|
|
||||||
|
echo ""
|
||||||
echo "----"
|
echo "----"
|
||||||
|
|
||||||
echo "pull-request-exists=false" >> "$GITHUB_OUTPUT"
|
echo "pull-request-exists=false" >> "$GITHUB_OUTPUT"
|
||||||
@@ -463,9 +458,9 @@ jobs:
|
|||||||
HTTP_STATUS=$(curl -X POST -s -w '%{http_code}' -o response_body.json --data "$PAYLOAD" -H "Authorization: token ${GITEA_TOKEN}" -H "Content-Type: application/json" "$API_ENDPOINT")
|
HTTP_STATUS=$(curl -X POST -s -w '%{http_code}' -o response_body.json --data "$PAYLOAD" -H "Authorization: token ${GITEA_TOKEN}" -H "Content-Type: application/json" "$API_ENDPOINT")
|
||||||
|
|
||||||
if [ "$HTTP_STATUS" == "201" ]; then
|
if [ "$HTTP_STATUS" == "201" ]; then
|
||||||
echo ""
|
|
||||||
echo ">> Pull Request created successfully!"
|
echo ">> Pull Request created successfully!"
|
||||||
|
|
||||||
|
echo ""
|
||||||
echo "----"
|
echo "----"
|
||||||
|
|
||||||
echo "pull-request-url=$(jq -r .html_url response_body.json)" >> "$GITHUB_OUTPUT"
|
echo "pull-request-url=$(jq -r .html_url response_body.json)" >> "$GITHUB_OUTPUT"
|
||||||
@@ -477,10 +472,16 @@ jobs:
|
|||||||
echo ""
|
echo ""
|
||||||
echo ">> Failed to create PR (Already exists)"
|
echo ">> Failed to create PR (Already exists)"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "----"
|
||||||
|
|
||||||
else
|
else
|
||||||
echo ""
|
echo ""
|
||||||
echo ">> Failed to create PR, HTTP status code: $HTTP_STATUS"; exit 1
|
echo ">> Failed to create PR, HTTP status code: $HTTP_STATUS"; exit 1
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "----"
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Merge Changes
|
- name: Merge Changes
|
||||||
@@ -500,17 +501,19 @@ jobs:
|
|||||||
HTTP_STATUS=$(curl -X POST -s -w '%{http_code}' -o response_body.json --data "$PAYLOAD" -H "Authorization: token ${GITEA_TOKEN}" -H "Content-Type: application/json" "$API_ENDPOINT")
|
HTTP_STATUS=$(curl -X POST -s -w '%{http_code}' -o response_body.json --data "$PAYLOAD" -H "Authorization: token ${GITEA_TOKEN}" -H "Content-Type: application/json" "$API_ENDPOINT")
|
||||||
|
|
||||||
if [ "$HTTP_STATUS" == "200" ]; then
|
if [ "$HTTP_STATUS" == "200" ]; then
|
||||||
echo ""
|
|
||||||
echo ">> Pull Request merged successfully!"
|
echo ">> Pull Request merged successfully!"
|
||||||
|
|
||||||
|
echo ""
|
||||||
echo "----"
|
echo "----"
|
||||||
|
|
||||||
echo "pull-request-operation=merged" >> "$GITHUB_OUTPUT"
|
echo "pull-request-operation=merged" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
else
|
else
|
||||||
echo ""
|
|
||||||
echo ">> Failed to merge PR, HTTP status code: $HTTP_STATUS"; exit 1
|
echo ">> Failed to merge PR, HTTP status code: $HTTP_STATUS"; exit 1
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "----"
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Cleanup Branch
|
- name: Cleanup Branch
|
||||||
@@ -520,10 +523,10 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
cd "${MANIFEST_DIR}"
|
cd "${MANIFEST_DIR}"
|
||||||
|
|
||||||
echo ""
|
|
||||||
echo ">> Removing branch: ${BRANCH_NAME}"
|
echo ">> Removing branch: ${BRANCH_NAME}"
|
||||||
git push origin --delete "${BRANCH_NAME}" || true
|
git push origin --delete "${BRANCH_NAME}" || true
|
||||||
|
|
||||||
|
echo ""
|
||||||
echo "----"
|
echo "----"
|
||||||
|
|
||||||
- name: ntfy Created
|
- name: ntfy Created
|
||||||
|
|||||||
Reference in New Issue
Block a user