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

78 lines
2.3 KiB
YAML
Raw Normal View History

2024-11-12 17:00:34 +00:00
name: Release Charts
on:
push:
branches:
- 'main'
paths:
- 'charts/**'
2024-11-12 17:00:34 +00:00
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.REPO_TOKEN }}
2024-11-12 17:00:34 +00:00
run: |
charts='${{ needs.charts-changed.outputs.reposChanged }}'
for chart in $(echo $charts | jq -r '.[]'); do
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")
export TAG="$CHART_NAME-$CHART_VERSION"
export FORGEJO_TOKEN="${{ secrets.REPO_TOKEN }}"
export REPO="${{ github.repository }}"
export RELEASE_DIR="dist"
export RELEASE_NOTES="/var/ci-os/templates/release-notes-template.md"
export SHA="${{ github.sha }}"
2024-11-12 18:52:00 +00:00
echo "=================="
echo "Chart: $chart"
echo "Uploading to: $OCI_URL"
2024-11-12 18:52:00 +00:00
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://code.252.no/tommy/charts
2024-11-12 18:52:00 +00:00
echo "------------------"
2024-11-12 18:52:00 +00:00
echo "Creating release"
echo "Repository: $REPO"
echo "Tag: $TAG"
echo "Release notes: $RELEASE_NOTES"
echo "Release dir: $RELEASE_DIR"
echo "SHA: $SHA"
2024-11-12 17:00:34 +00:00
forgejo-release create
echo "=================="
2024-11-12 17:00:34 +00:00
done