Files
matrix-alertmanager-receiver/.gitea/workflows/chart.yml
T
feedc0de 3da15981bd
Validate, publish and promote Matrix Alertmanager receiver chart / validate (push) Successful in 20s
Validate, publish and promote Matrix Alertmanager receiver chart / publish (push) Successful in 31s
Add Helm chart for Matrix Alertmanager receiver
2026-10-21 18:54:33 +02:00

87 lines
3.1 KiB
YAML

name: Validate, publish and promote Matrix Alertmanager receiver chart
on:
push:
pull_request:
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: azure/setup-helm@v4
with:
version: v4.3.0
- name: Install chart-test dependency
run: |
python3 -m venv "${RUNNER_TEMP}/chart-test"
"${RUNNER_TEMP}/chart-test/bin/pip" install PyYAML
echo "${RUNNER_TEMP}/chart-test/bin" >> "${GITHUB_PATH}"
- run: ./test.sh
publish:
if: gitea.event_name == 'push' && gitea.ref == 'refs/heads/main'
needs: validate
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: azure/setup-helm@v4
with:
version: v4.3.0
- name: Select immutable chart version
run: echo "CHART_VERSION=$(./scripts/chart-version.sh)" >> "${GITHUB_ENV}"
- name: Package and publish chart
env:
PACKAGE_USERNAME: ${{ secrets.PACKAGE_USERNAME }}
PACKAGE_TOKEN: ${{ secrets.PACKAGE_TOKEN }}
run: |
set -euo pipefail
test -n "${PACKAGE_USERNAME}" && test -n "${PACKAGE_TOKEN}"
helm package chart/matrix-alertmanager-receiver \
--destination "${RUNNER_TEMP}" \
--version "${CHART_VERSION}"
curl --fail --silent --show-error \
--user "${PACKAGE_USERNAME}:${PACKAGE_TOKEN}" \
--request POST \
--upload-file "${RUNNER_TEMP}/matrix-alertmanager-receiver-${CHART_VERSION}.tgz" \
https://code.brunner.ninja/api/packages/feedc0de/helm/api/charts
- name: Check that this is still current main
id: current-main
env:
COMMIT_SHA: ${{ gitea.sha }}
run: |
git fetch --no-tags origin main
if [ "$(git rev-parse FETCH_HEAD)" = "${COMMIT_SHA}" ]; then
echo "promote=true" >> "${GITHUB_OUTPUT}"
else
echo "promote=false" >> "${GITHUB_OUTPUT}"
fi
- uses: actions/checkout@v4
if: steps.current-main.outputs.promote == 'true'
with:
repository: feedc0de/homelab-gitops
ref: main
token: ${{ secrets.GITOPS_TOKEN }}
path: homelab-gitops
- name: Promote chart version
if: steps.current-main.outputs.promote == 'true'
working-directory: homelab-gitops
run: |
set -euo pipefail
./scripts/update-chart-version.sh matrix-alertmanager-receiver "${CHART_VERSION}"
git config user.name feedc0de
git config user.email feedc0de@users.noreply.code.brunner.ninja
git add bootstrap/matrix-alertmanager-receiver.yaml
if git diff --cached --quiet; then exit 0; fi
git commit -m "Deploy Matrix receiver chart ${CHART_VERSION}"
for attempt in 1 2 3; do
if git push origin HEAD:main; then exit 0; fi
if [ "${attempt}" = 3 ]; then exit 1; fi
git fetch origin main
git rebase origin/main
done