charts/.forgejo/workflows/release-charts.yaml

69 lines
2 KiB
YAML

name: Release Charts
on:
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 "::set-output name=reposChanged::$changed" # Sets output as a JSON array
fi
outputs:
reposChanged: ${{ steps.changed-charts.outputs.reposChanged }}
changesExist: ${{ env.changesExist }}
helm-publish:
name: "Publish Helm Chart"
needs: charts-changed
if: 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.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
RELEASE_DIR: dist
RELEASE_NOTES: /var/ci-os/templates/release-notes-template.md
SHA: ${{ github.sha }}
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")
export TAG="$CHART_NAME-$CHART_VERSION"
echo "packing $chart"
helm package "$chart" -d dist
curl --user ${{ github.repository_owner }}:${{ secrets.REGISTRY_TOKEN }} \
--upload-file "dist/$TAG.tgz" \
https://code.252.no/api/packages/${{ github.repository_owner }}/generic/$CHART_NAME/$CHART_VERSION/$TAG.tgz
echo "$RELEASE_NOTES"
echo "$TAG"
forgejo-release create
done