Compare commits
3 commits
4282162608
...
bc4ae07d6a
Author | SHA1 | Date | |
---|---|---|---|
bc4ae07d6a | |||
c95d09283f | |||
2bd7fee2b8 |
1 changed files with 24 additions and 26 deletions
|
@ -1,5 +1,10 @@
|
||||||
name: Release Charts
|
name: Release Charts
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
pull_request:
|
||||||
|
paths:
|
||||||
|
- 'charts/**'
|
||||||
|
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- 'main'
|
- 'main'
|
||||||
|
@ -8,7 +13,7 @@ on:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
charts-changed:
|
charts-changed:
|
||||||
name: Get Charts being Changed
|
name: Get Charts Being Changed
|
||||||
runs-on: ci-os
|
runs-on: ci-os
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- 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))')
|
changed=$(ct --config .forgejo/ct.yaml list-changed | tr '\n' ' ' | jq -R -s -c 'split(" ") | map(select(length > 0))')
|
||||||
if [[ -n "$changed" ]]; then
|
if [[ -n "$changed" ]]; then
|
||||||
echo "changesExist=true" >> $GITHUB_ENV
|
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
|
fi
|
||||||
outputs:
|
outputs:
|
||||||
reposChanged: ${{ steps.changed-charts.outputs.reposChanged }}
|
|
||||||
changesExist: ${{ env.changesExist }}
|
changesExist: ${{ env.changesExist }}
|
||||||
|
reposChanged: ${{ env.reposChanged }}
|
||||||
|
|
||||||
helm-publish:
|
helm-publish:
|
||||||
name: "Publish Helm Chart"
|
name: "Publish Helm Chart"
|
||||||
needs: charts-changed
|
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
|
runs-on: ci-os
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Publish
|
- name: Publish
|
||||||
env:
|
env:
|
||||||
FORGEJO_TOKEN: ${{ secrets.REPO_TOKEN }}
|
FORGEJO_TOKEN: ${{ secrets.REPO_TOKEN }}
|
||||||
run: |
|
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
|
rm -rf dist || true
|
||||||
mkdir dist || true
|
mkdir dist || true
|
||||||
|
|
||||||
CHART_NAME=$(yq -r .name "$chart/Chart.yaml")
|
CHART_NAME=$(yq -r .name "$chart/Chart.yaml")
|
||||||
CHART_VERSION=$(yq -r .version "$chart/Chart.yaml")
|
CHART_VERSION=$(yq -r .version "$chart/Chart.yaml")
|
||||||
export TAG="$CHART_NAME-$CHART_VERSION"
|
TAG="$CHART_NAME-$CHART_VERSION"
|
||||||
export FORGEJO_TOKEN="${{ secrets.REPO_TOKEN }}"
|
OCI_URL="oci://code.252.no/tommy/charts"
|
||||||
export REPO="${{ github.repository }}"
|
|
||||||
export RELEASE_DIR="dist"
|
|
||||||
export RELEASE_NOTES="/var/ci-os/templates/release-notes-template.md"
|
|
||||||
export SHA="${{ github.sha }}"
|
|
||||||
|
|
||||||
echo "=================="
|
echo "=================="
|
||||||
echo "Chart: $chart"
|
echo "Packaging and pushing chart: $chart with tag $TAG to $OCI_URL"
|
||||||
echo "Uploading to: $OCI_URL"
|
|
||||||
helm package "$chart" -d dist
|
helm package "$chart" -d dist
|
||||||
echo "${{ secrets.REPO_TOKEN }}"|helm registry login code.252.no -u tommy --password-stdin
|
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
|
helm push "dist/$TAG.tgz" "$OCI_URL"
|
||||||
|
|
||||||
echo "------------------"
|
echo "Creating release on Forgejo"
|
||||||
|
forgejo-release create --repo "${{ github.repository }}" --tag "$TAG" --notes "${{ env.RELEASE_NOTES }}" --sha "${{ github.sha }}"
|
||||||
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 "=================="
|
echo "=================="
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in a new issue