Skip to content

Merge pull request #33 from lalithkota/develop #33

Merge pull request #33 from lalithkota/develop

Merge pull request #33 from lalithkota/develop #33

Workflow file for this run

name: Publish OpenG2P Helm charts on
on:
push:
tags-ignore:
- '**'
branches:
- 1.*
- develop
- main
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
for chartpath in charts/*/; do
if [ -f ${chartpath}Chart.yaml ]; then
helm dep up $chartpath
fi
done
RANCHER_CHARTS=()
while IFS= read -r chartpath; do
echo "chartpath: $chartpath"
chartname=$(basename "$chartpath")
if [ -f charts/${chartname}/Chart.yaml ]; then
echo "Chartname: $chartname"
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
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@v2
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@v2
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 social registry helm charts for publish openg2p/openg2p-social-registry-deployment@${{ github.sha }}'
add: './*.tgz ./index.yaml rancher/index.yaml'
if: env.SKIP != 'TRUE'