Merge branch 'main' into attic-hardening
All checks were successful
Release Charts / Get Charts Being Changed (pull_request) Successful in 8s
Validate Charts / Get Charts being Changed (pull_request) Successful in 7s
Release Charts / Publish Helm Chart (pull_request) Has been skipped
Validate Charts / Lint (pull_request) Successful in 7s
Validate Charts / Audit (pull_request) Successful in 7s
Validate Charts / Outdated APIs (pull_request) Successful in 6s

This commit is contained in:
Tommy 2024-11-14 21:35:41 +00:00 committed by Mooo[bot]
commit bc4ae07d6a
Signed by: Mooo[bot]
GPG key ID: CF3AFE4D5B62BB9A

View file

@ -1,5 +1,10 @@
name: Release Charts
on:
pull_request:
paths:
- 'charts/**'
push:
branches:
- 'main'
@ -8,7 +13,7 @@ on:
jobs:
charts-changed:
name: Get Charts being Changed
name: Get Charts Being Changed
runs-on: ci-os
steps:
- name: Checkout
@ -22,56 +27,49 @@ jobs:
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
echo "reposChanged=$changed" >> $GITHUB_ENV
else
echo "changesExist=false" >> $GITHUB_ENV
echo "reposChanged=[]" >> $GITHUB_ENV
fi
outputs:
reposChanged: ${{ steps.changed-charts.outputs.reposChanged }}
changesExist: ${{ env.changesExist }}
reposChanged: ${{ env.reposChanged }}
helm-publish:
name: "Publish Helm Chart"
needs: charts-changed
if: needs.charts-changed.outputs.changesExist == 'true'
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 }}'
charts="${{ needs.charts-changed.outputs.reposChanged }}"
for chart in $(echo $charts | jq -r '.[]'); do
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"
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 }}"
TAG="$CHART_NAME-$CHART_VERSION"
OCI_URL="oci://code.252.no/tommy/charts"
echo "=================="
echo "Chart: $chart"
echo "Uploading to: $OCI_URL"
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://code.252.no/tommy/charts
echo "${{ secrets.REPO_TOKEN }}" | helm registry login code.252.no -u tommy --password-stdin
helm push "dist/$TAG.tgz" "$OCI_URL"
echo "------------------"
echo "Creating release"
echo "Repository: $REPO"
echo "Tag: $TAG"
echo "Release notes: $RELEASE_NOTES"
echo "Release dir: $RELEASE_DIR"
echo "SHA: $SHA"
forgejo-release create
echo "Creating release on Forgejo"
forgejo-release create --repo "${{ github.repository }}" --tag "$TAG" --notes "${{ env.RELEASE_NOTES }}" --sha "${{ github.sha }}"
echo "=================="
done