75 lines
2.2 KiB
YAML
75 lines
2.2 KiB
YAML
name: Release Charts
|
|
|
|
on:
|
|
pull_request:
|
|
paths:
|
|
- 'charts/**'
|
|
|
|
push:
|
|
branches:
|
|
- 'main'
|
|
paths:
|
|
- 'charts/**'
|
|
|
|
jobs:
|
|
charts-changed:
|
|
name: Get Charts Being Changed
|
|
runs-on: ci-os
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: List changed charts
|
|
id: changed-charts
|
|
run: |
|
|
changed=$(ct --config .forgejo/ct.yaml list-changed | tr '\n' ' ' | jq -R -s -c 'split(" ") | map(select(length > 0))')
|
|
if [[ -n "$changed" ]]; then
|
|
echo "changesExist=true" >> $GITHUB_ENV
|
|
echo "reposChanged=$changed" >> $GITHUB_ENV
|
|
else
|
|
echo "changesExist=false" >> $GITHUB_ENV
|
|
echo "reposChanged=[]" >> $GITHUB_ENV
|
|
fi
|
|
outputs:
|
|
changesExist: ${{ env.changesExist }}
|
|
reposChanged: ${{ env.reposChanged }}
|
|
|
|
helm-publish:
|
|
name: "Publish Helm Chart"
|
|
needs: charts-changed
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main' &&
|
|
needs.charts-changed.outputs.changesExist == 'true'
|
|
runs-on: ci-os
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Publish
|
|
env:
|
|
FORGEJO_TOKEN: ${{ secrets.REPO_TOKEN }}
|
|
run: |
|
|
charts="${{ needs.charts-changed.outputs.reposChanged }}"
|
|
|
|
for chart in $(echo "$charts" | jq -r '.[]'); do
|
|
rm -rf dist || true
|
|
mkdir dist || true
|
|
|
|
CHART_NAME=$(yq -r .name "$chart/Chart.yaml")
|
|
CHART_VERSION=$(yq -r .version "$chart/Chart.yaml")
|
|
TAG="$CHART_NAME-$CHART_VERSION"
|
|
OCI_URL="oci://code.252.no/tommy/charts"
|
|
|
|
echo "=================="
|
|
echo "Packaging and pushing chart: $chart with tag $TAG to $OCI_URL"
|
|
helm package "$chart" -d dist
|
|
echo "${{ secrets.REPO_TOKEN }}" | helm registry login code.252.no -u tommy --password-stdin
|
|
helm push "dist/$TAG.tgz" "$OCI_URL"
|
|
|
|
echo "Creating release on Forgejo"
|
|
forgejo-release create --repo "${{ github.repository }}" --tag "$TAG" --notes "${{ env.RELEASE_NOTES }}" --sha "${{ github.sha }}"
|
|
echo "=================="
|
|
done
|