61 lines
2.1 KiB
YAML
61 lines
2.1 KiB
YAML
name: Publish and promote Helm chart
|
|
on:
|
|
push:
|
|
pull_request:
|
|
jobs:
|
|
chart:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with: {fetch-depth: 0}
|
|
- uses: azure/setup-helm@v4
|
|
- name: Lint and render
|
|
run: |
|
|
helm lint chart --set externalIP=192.0.2.1
|
|
helm template coturn chart --set externalIP=192.0.2.1 >/dev/null
|
|
- name: Publish
|
|
if: gitea.ref == 'refs/heads/main'
|
|
run: |
|
|
version=$(./scripts/chart-version.sh)
|
|
echo "CHART_VERSION=${version}" >> "${GITHUB_ENV}"
|
|
mkdir -p dist
|
|
helm package chart --destination dist --version "${version}"
|
|
curl --fail-with-body --user "${{ secrets.PACKAGE_USERNAME }}:${{ secrets.PACKAGE_TOKEN }}" \
|
|
--request POST \
|
|
--upload-file "dist/coturn-${version}.tgz" \
|
|
https://code.brunner.ninja/api/packages/feedc0de/helm/api/charts
|
|
- name: Check that this is still current main
|
|
if: gitea.ref == 'refs/heads/main'
|
|
run: |
|
|
git fetch --no-tags origin main
|
|
test "$(git rev-parse FETCH_HEAD)" = "${GITEA_SHA}"
|
|
- name: Check out GitOps
|
|
if: gitea.ref == 'refs/heads/main'
|
|
uses: actions/checkout@v4
|
|
with:
|
|
repository: feedc0de/homelab-gitops
|
|
ref: main
|
|
token: ${{ secrets.GITOPS_TOKEN }}
|
|
path: homelab-gitops
|
|
- name: Promote
|
|
if: gitea.ref == 'refs/heads/main'
|
|
working-directory: homelab-gitops
|
|
run: |
|
|
./scripts/update-chart-version.sh coturn "${CHART_VERSION}"
|
|
git config user.name feedc0de
|
|
git config user.email feedc0de@users.noreply.code.brunner.ninja
|
|
git add bootstrap/coturn.yaml
|
|
if git diff --cached --quiet; then exit 0; fi
|
|
git commit -m "Deploy coturn chart ${CHART_VERSION}"
|
|
for attempt in 1 2 3; do
|
|
if git push origin HEAD:main; then
|
|
exit 0
|
|
fi
|
|
if [ "${attempt}" = 3 ]; then
|
|
echo "GitOps promotion failed after three attempts" >&2
|
|
exit 1
|
|
fi
|
|
git fetch origin main
|
|
git rebase origin/main
|
|
done
|