Add support for YAML (and JSON) config #61
Workflow file for this run
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
name: Helm Chart Lint and Release | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
workflow_dispatch: | |
jobs: | |
helm-lint: | |
name: Helm lint | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repo hosting code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up Helm | |
uses: azure/setup-helm@v3 | |
- name: Run helm lint | |
run: helm lint cloudprober/. | |
paths-filter: | |
name: Filter Chart.yaml | |
outputs: | |
charts_yaml_changing: ${{ steps.filter.outputs.chartYaml }} | |
runs-on: ubuntu-latest | |
needs: [helm-lint] | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: dorny/paths-filter@v2 | |
id: filter | |
with: | |
filters: | | |
chartYaml: | |
- 'cloudprober/Chart.yaml' | |
chart-release: | |
name: Release chart | |
runs-on: ubuntu-latest | |
needs: [paths-filter, helm-lint] | |
if: needs.paths-filter.outputs.charts_yaml_changing == 'true' | |
steps: | |
- name: Check out repo hosting code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- uses: dorny/paths-filter@v2 | |
id: filter | |
with: | |
filters: | | |
chartYaml: | |
- 'cloudprober/Chart.yaml' | |
- name: Compute chart version | |
run: |- | |
baseVersion=$(sed -n '/version: /s/version: //p' cloudprober/Chart.yaml) | |
echo ">> Base version: $baseVersion" | |
bv=( ${baseVersion//./ } ) | |
appVersion=$(sed -n '/appVersion: /s/appVersion: //p' cloudprober/Chart.yaml) | |
echo ">> App version: $appVersion" | |
cpVersion=${appVersion/v/} | |
cpVersion=$(echo $cpVersion | tr -d "'") | |
echo ">> Cloudprober version: $cpVersion" | |
cv=( ${cpVersion//./ } ) | |
newVersion=$((${bv[0]} + ${cv[0]})).$((${bv[1]} + ${cv[1]})).$((${bv[2]} + ${cv[2]})) | |
echo ">> New version: $newVersion" | |
echo "CHART_VERSION=${newVersion}" >> $GITHUB_ENV | |
- name: Set up Helm | |
uses: azure/setup-helm@v3 | |
- name: Create tag | |
uses: actions/github-script@v5 | |
with: | |
script: | | |
github.rest.git.createRef({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
ref: 'refs/tags/${{ env.CHART_VERSION }}', | |
sha: context.sha | |
}) | |
- name: Package chart and build index | |
run: |- | |
git worktree add repo gh-pages | |
cd repo | |
helm package ../cloudprober/. --version=${CHART_VERSION} -d packages | |
helm repo index . --url https://helm.cloudprober.org | |
git add * | |
git status | |
- name: Push release | |
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags') | |
run: |- | |
cd repo | |
git add * | |
git config user.name "Manu Garg" | |
git config user.email "manugarg@gmail.com" | |
git commit -m "[automated] Update helm charts repo" || exit 0 | |
git push |