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

76 lines
2.2 KiB
YAML
Raw Normal View History

2024-11-12 17:00:34 +00:00
name: Release Charts
2024-11-14 21:33:51 +00:00
2024-11-12 17:00:34 +00:00
on:
2024-11-14 21:33:51 +00:00
pull_request:
paths:
- 'charts/**'
push:
branches:
- 'main'
paths:
- 'charts/**'
2024-11-12 17:00:34 +00:00
jobs:
charts-changed:
2024-11-14 21:33:51 +00:00
name: Get Charts Being Changed
2024-11-12 17:00:34 +00:00
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
2024-11-14 21:33:51 +00:00
echo "reposChanged=$changed" >> $GITHUB_ENV
else
echo "changesExist=false" >> $GITHUB_ENV
echo "reposChanged=[]" >> $GITHUB_ENV
2024-11-12 17:00:34 +00:00
fi
outputs:
changesExist: ${{ env.changesExist }}
2024-11-14 21:33:51 +00:00
reposChanged: ${{ env.reposChanged }}
2024-11-12 17:00:34 +00:00
helm-publish:
name: "Publish Helm Chart"
needs: charts-changed
2024-11-14 21:33:51 +00:00
if: github.event_name == 'push' && github.ref == 'refs/heads/main' &&
needs.charts-changed.outputs.changesExist == 'true'
2024-11-12 17:00:34 +00:00
runs-on: ci-os
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
2024-11-14 21:33:51 +00:00
2024-11-12 17:00:34 +00:00
- name: Publish
env:
FORGEJO_TOKEN: ${{ secrets.REPO_TOKEN }}
2024-11-12 17:00:34 +00:00
run: |
2024-11-14 21:33:51 +00:00
charts="${{ needs.charts-changed.outputs.reposChanged }}"
2024-11-12 17:00:34 +00:00
2024-11-14 21:33:51 +00:00
for chart in $(echo "$charts" | jq -r '.[]'); do
2024-11-12 17:00:34 +00:00
rm -rf dist || true
mkdir dist || true
2024-11-12 18:52:00 +00:00
2024-11-12 17:00:34 +00:00
CHART_NAME=$(yq -r .name "$chart/Chart.yaml")
CHART_VERSION=$(yq -r .version "$chart/Chart.yaml")
2024-11-14 21:33:51 +00:00
TAG="$CHART_NAME-$CHART_VERSION"
OCI_URL="oci://code.252.no/tommy/charts"
echo "=================="
2024-11-14 21:33:51 +00:00
echo "Packaging and pushing chart: $chart with tag $TAG to $OCI_URL"
2024-11-12 18:52:00 +00:00
helm package "$chart" -d dist
2024-11-14 21:33:51 +00:00
echo "${{ secrets.REPO_TOKEN }}" | helm registry login code.252.no -u tommy --password-stdin
helm push "dist/$TAG.tgz" "$OCI_URL"
2024-11-12 18:52:00 +00:00
2024-11-14 21:33:51 +00:00
echo "Creating release on Forgejo"
forgejo-release create --repo "${{ github.repository }}" --tag "$TAG" --notes "${{ env.RELEASE_NOTES }}" --sha "${{ github.sha }}"
echo "=================="
2024-11-12 17:00:34 +00:00
done