Skip to content

Merge pull request #13 from PSNAppz/1.0 #6

Merge pull request #13 from PSNAppz/1.0

Merge pull request #13 from PSNAppz/1.0 #6

name: Publish OpenG2P Helm charts
on:
push:
tags:
- '**'
branches-ignore:
- develop
- main
workflow_dispatch:
jobs:
generate-charts:
runs-on: ubuntu-latest
env:
SKIP: 'FALSE'
RANCHER_CHART_FILTER: "openg2p.org/add-to-rancher"
defaults:
run:
shell: bash
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- id: files
uses: jitterbit/get-changed-files@v1
- name: save helm/charts to tmp.txt file
run: |
touch charts-list.txt
for changed_file in ${{ steps.files.outputs.all }}; do
if [[ ${changed_file} =~ ^charts ]]; then
chart_name=$(echo "${changed_file}" | awk -F/ '/^[charts]/{print $2}')
echo $chart_name >> charts-list.txt;
echo "Saved $chart_name chart to charts-list.txt"
fi
done
cat charts-list.txt | sort | uniq > charts-list-unique.txt
mv charts-list-unique.txt charts-list.txt
echo "List of charts to be published";
cat charts-list.txt
- name: Generate tar files
run: |
if [[ ! -s charts-list.txt ]]; then
echo "::warning::No Charts to publish";
echo "SKIP=TRUE" >> $GITHUB_ENV
else
RANCHER_CHARTS=()
while IFS= read -r chartpath; do
echo "chartpath: $chartpath"
chartname=$(basename "$chartpath")
echo "Chartname: $chartname"
helm dep up charts/$chartpath
helm package charts/$chartpath
is_rancher_chart=$(grep "$RANCHER_CHART_FILTER" charts/${chartpath%*/}/Chart.yaml || true)
if [ -n "$is_rancher_chart" ]; then
RANCHER_CHARTS+=("$chartname")
fi
done < charts-list.txt
echo "RANCHER_CHARTS=${RANCHER_CHARTS[@]}" >> $GITHUB_ENV
rm charts-list.txt
fi
shopt -s nocasematch
if [[ '${{ github.repository_owner }}' != 'OpenG2P' ]]; then
echo "SKIP=TRUE" >> $GITHUB_ENV
fi
- name: Upload tar as Artifact
uses: actions/upload-artifact@v4
with:
name: charts
path: ./*.tgz
if: env.SKIP != 'TRUE'
- name: Checkout branch for publishing
uses: actions/checkout@v3
with:
repository: 'openg2p/openg2p-helm'
ref: gh-pages
token: ${{ secrets.OPENG2P_BOT_GITHUB_PAT }}
if: env.SKIP != 'TRUE'
- name: Download tar from Artifacts
uses: actions/download-artifact@v4
with:
name: charts
path: ./
if: env.SKIP != 'TRUE'
- name: Update index.yaml
run: |
helm repo index --url https://openg2p.github.io/openg2p-helm/ .
for chartname in $RANCHER_CHARTS; do
cp ${chartname}*.tgz rancher/
done
helm repo index --url https://openg2p.github.io/openg2p-helm/ --merge rancher/index.yaml rancher
for chartname in $RANCHER_CHARTS; do
rm rancher/${chartname}*.tgz || true
done
if: env.SKIP != 'TRUE'
- name: Commit Changes to repository
uses: EndBug/add-and-commit@v7
with:
branch: gh-pages
author_name: openg2pbot
author_email: [email protected]
default_author: user_info
message: 'added spar helm charts for publish openg2p/openg2p-spar-deployment@${{ github.sha }}'
add: './*.tgz ./index.yaml rancher/index.yaml'
if: env.SKIP != 'TRUE'