🔀 :: git action #39
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Reference: https://github.com/helm/chart-releaser-action | |
name: Chart Publish | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- "helm/**" | |
permissions: | |
contents: read | |
jobs: | |
publish: | |
permissions: | |
contents: write | |
packages: write | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/[email protected] | |
with: | |
fetch-depth: 0 | |
- name: Install Helm | |
uses: azure/[email protected] | |
with: | |
version: v3.10.1 # Also update in lint-and-test.yaml | |
- name: Add helm repo | |
working-directory: helm | |
run: | | |
function random_name() { | |
echo $(LC_ALL=C tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w 12 | head -n 1) | |
} | |
find . -mindepth 1 -maxdepth 1 -type d | | |
while IFS= read -r package_directory; do | |
helm dependency update $(basename "$package_directory") | |
done | |
while IFS= read -r chart_lock_file; do | |
while IFS= read -r repo; do | |
if [ -n "$repo" ]; then | |
helm repo add $random_name() $repo || true | |
fi | |
done <<< $(yq eval '.dependencies[] | .repository' "$chart_lock_file") # repos | |
done <<< "$(find . -mindepth 2 -maxdepth 2 -name "Chart.lock") # chart lock files | |
- name: Helm build | |
working-directory: helm | |
run: | | |
find . -mindepth 1 -maxdepth 1 -type d | | |
while IFS= read -r package_directory; do | |
dir_name=$(basename "$package_directory") | |
helm dependency build $dir_name | |
helm package $dir_name | |
done | |
- name: Get Helm package | |
id: helm_package | |
run: | | |
package_list=$(find . -type f -mindepth 1 -maxdepth 1 -name "*.tgz" -exec basename {} \; | tr '\n' ' ') | |
echo $package_list | |
echo "package_list=$package_list" >> $GITHUB_OUTPUT | |
- name: Checkout gh-pages branch | |
uses: actions/checkout@v2 | |
with: | |
ref: gh-pages | |
- name: Get *.tgz files | |
run: | | |
git checkout main -- ${{ steps.helm_package.outputs.package_list }} | |
- name: Commit The Chart Realease | |
uses: stefanzweifel/git-auto-commit-action@v4 | |
with: | |
commit_message: "update :: new chart realease" | |
branch: gh-pages | |
commit_options: '--no-verify --signoff' | |
repository: . | |
commit_user_name: XQUARE GitOps Bot | |
commit_user_email: [email protected] | |
commit_author: XQUARE GitOps Bot <[email protected]> |