From 0b611db030dbfac97fa331a27c5758d1ffc356dc Mon Sep 17 00:00:00 2001 From: Alan Bridgeman Date: Thu, 18 Dec 2025 22:34:47 -0600 Subject: [PATCH] Small update/correction to README + uncommenting chunk of Forgejo Action automation --- .forgejo/workflows/deploy.yml | 130 +++++++++++++++++----------------- README.md | 2 +- 2 files changed, 66 insertions(+), 66 deletions(-) diff --git a/.forgejo/workflows/deploy.yml b/.forgejo/workflows/deploy.yml index 2bee912..ff931ea 100644 --- a/.forgejo/workflows/deploy.yml +++ b/.forgejo/workflows/deploy.yml @@ -31,27 +31,27 @@ jobs: # Note, this depends on the [Harbor Helm Index](https://git.bridgemanaccessible.ca/Bridgeman-Accessible/harbor-helm-index) pretty heavily # In particular, that tool allows us to treat what is an OCI registry as a Helm repository (which includes using `helm search repo`) - #helm repo add BridgemanAccessible https://helm.bridgemanaccessible.ca + helm repo add BridgemanAccessible https://helm.bridgemanaccessible.ca # Check if the chart is already in the repository or not - #REMOTE_CHART_WORK_OUTPUT=$(helm search repo BridgemanAccessible/$CHART_NAME 2>/dev/null || echo "") - #if [ -n "$REMOTE_CHART_WORK_OUTPUT" ]; then - # # The chart is already in the repository, so we need to check if the version is the same or not - # echo "Chart already exists in the repository. Checking version..." - # - # IFS=' ' read -r -a REMOTE_VERSIONS <<< $(helm search repo BridgemanAccessible/$CHART_NAME --output json | jq '.[].version | @sh') - # - # echo "Remote Chart Versions: ${REMOTE_VERSIONS[@]}" - #else - # # The chart is not in the repository, so we'll need to add it - # echo "Chart not found in the repository. Adding it..." - # - # # Set a blank value so that it WON'T match the local version - # IFS=' ' read -r -a REMOTE_VERSIONS <<< "" - #fi + REMOTE_CHART_WORK_OUTPUT=$(helm search repo BridgemanAccessible/$CHART_NAME 2>/dev/null || echo "") + if [ -n "$REMOTE_CHART_WORK_OUTPUT" ]; then + # The chart is already in the repository, so we need to check if the version is the same or not + echo "Chart already exists in the repository. Checking version..." + + IFS=' ' read -r -a REMOTE_VERSIONS <<< $(helm search repo BridgemanAccessible/$CHART_NAME --output json | jq '.[].version | @sh') + + echo "Remote Chart Versions: ${REMOTE_VERSIONS[@]}" + else + # The chart is not in the repository, so we'll need to add it + echo "Chart not found in the repository. Adding it..." + + # Set a blank value so that it WON'T match the local version + IFS=' ' read -r -a REMOTE_VERSIONS <<< "" + fi # Just to keep things clean/safe/etc... remove the repo - #helm repo remove BridgemanAccessible + helm repo remove BridgemanAccessible # Get the local version from the Chart.yaml file LOCAL_VERSION=$(yq '.version' Chart.yaml) @@ -59,57 +59,57 @@ jobs: LOCAL_VERSION=${LOCAL_VERSION%\"} # Remove trailing quote echo "Local Chart Version: $LOCAL_VERSION" - #has_match='false' - #if [ ${#REMOTE_VERSIONS[@]} -gt 0 ]; then - # # Loop through the remote tags and check if any of them match the local version - # for REMOTE_VERSION in ${REMOTE_VERSIONS[@]}; do - # REMOTE_VERSION=${REMOTE_VERSION#\'} # Remove leading quote - # REMOTE_VERSION=${REMOTE_VERSION%\'} # Remove trailing quote - # - # # Check if the remote tag is the same as the local tag - # if [ "$REMOTE_VERSION" == "$LOCAL_VERSION" ]; then - # echo "Remote version matches local version!" - # has_match='true' - # break - # fi - # done - #fi + has_match='false' + if [ ${#REMOTE_VERSIONS[@]} -gt 0 ]; then + # Loop through the remote tags and check if any of them match the local version + for REMOTE_VERSION in ${REMOTE_VERSIONS[@]}; do + REMOTE_VERSION=${REMOTE_VERSION#\'} # Remove leading quote + REMOTE_VERSION=${REMOTE_VERSION%\'} # Remove trailing quote + + # Check if the remote tag is the same as the local tag + if [ "$REMOTE_VERSION" == "$LOCAL_VERSION" ]; then + echo "Remote version matches local version!" + has_match='true' + break + fi + done + fi # If the versions match, we want to increment the chart's patch version - #if [ "has_match" ]; then - # echo "Versions match!" - # - # # Increment the patch version of the local version (Ex. 1.0.0 -> 1.0.1) - # IFS='.' read -r major minor patch <<< "$LOCAL_VERSION" - # patch=$((patch + 1)) - # NEW_LOCAL_VERSION="$major.$minor.$patch" - # - # echo "New Local Version: $NEW_LOCAL_VERSION" - # echo "Committing new chart version change..." - # - # sed -i "s|version: \"$LOCAL_VERSION\"|version: \"$NEW_LOCAL_VERSION\"|g" Chart.yaml - # - # LOCAL_VERSION=$NEW_LOCAL_VERSION - # - # # Update remote URL to use the GITHUB_TOKEN for authentication - # git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@git.bridgemanaccessible.ca/${{ github.repository }}.git - # - # # Setup git user details for committing the version change and tag - # git config user.name "Forgejo Actions" - # git config user.email "actions@git.bridgemanaccessible.ca" - # - # # Commit the version change to the `package.json` file - # git add Chart.yaml - # git commit -m "[Forgejo Actions] Update Helm chart version to $(yq -r '.version' Chart.yaml)" - # - # # Push the changes to the repository - # git push origin HEAD:main - #else - # echo "Versions do not match!" - #fi + if [ "has_match" ]; then + echo "Versions match!" + + # Increment the patch version of the local version (Ex. 1.0.0 -> 1.0.1) + IFS='.' read -r major minor patch <<< "$LOCAL_VERSION" + patch=$((patch + 1)) + NEW_LOCAL_VERSION="$major.$minor.$patch" + + echo "New Local Version: $NEW_LOCAL_VERSION" + echo "Committing new chart version change..." + + sed -i "s|version: \"$LOCAL_VERSION\"|version: \"$NEW_LOCAL_VERSION\"|g" Chart.yaml + + LOCAL_VERSION=$NEW_LOCAL_VERSION + + # Update remote URL to use the GITHUB_TOKEN for authentication + git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@git.bridgemanaccessible.ca/${{ github.repository }}.git + + # Setup git user details for committing the version change and tag + git config user.name "Forgejo Actions" + git config user.email "actions@git.bridgemanaccessible.ca" + + # Commit the version change to the `package.json` file + git add Chart.yaml + git commit -m "[Forgejo Actions] Update Helm chart version to $(yq -r '.version' Chart.yaml)" + + # Push the changes to the repository + git push origin HEAD:main + else + echo "Versions do not match!" + fi #helm package . - #helm push ./$CHART_NAME-$LOCAL_VERSION.tgz oci://${{ secrets.REPOSITORY_HOSTNAME }}/helm + #helm push ./$CHART_NAME-$LOCAL_VERSION.tgz oci://${{ secrets.REPOSITORY_HOSTNAME }}/helm # Deploy to our environment (stagging cluster) #deploy: @@ -121,7 +121,7 @@ jobs: # env: # NAMESPACE: custom-vault # RELEASE_NAME: custom-vault - # CHART_NAME: ${{ needs.build.outputs.chart-name }} + # CHART_NAME: ${{ needs.build.outputs.chart-name }} # steps: # # Deploy the resources to the cluster # - name: Deploy Helm Chart diff --git a/README.md b/README.md index abffa21..9d71ad6 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,6 @@ To use this chart as a dependency: dependencies: - name: ba-custom-hashicorp-vault version: 1.0.0 - repository: "https://charts.bridgemanaccessible.ca/" + repository: "https://helm.bridgemanaccessible.ca/" condition: vault.enabled ``` \ No newline at end of file