Files
feedc0de 36d4384d2d
Validate, publish and promote loops chart / validate (push) Successful in 1s
Validate, publish and promote loops chart / publish (push) Successful in 52s
Load Loops image for CI smoke tests
2026-10-26 07:00:29 +01:00

91 lines
3.9 KiB
YAML

name: Validate, publish and promote loops chart
on:
push:
pull_request:
jobs:
validate:
runs-on: linux_amd64
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Lint and render
run: ./scripts/test.sh
publish:
if: gitea.event_name == 'push' && gitea.ref == 'refs/heads/main'
needs: validate
runs-on: linux_amd64
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Derive release versions
run: |
set -euo pipefail
echo "CHART_VERSION=$(./scripts/chart-version.sh)" >> "$GITHUB_ENV"
echo "APP_VERSION=$(sed -n 's/^appVersion: \"\(.*\)\"$/\1/p' chart/Chart.yaml)" >> "$GITHUB_ENV"
- name: Build, test and publish Loops image
env:
QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }}
QUAY_TOKEN: ${{ secrets.QUAY_TOKEN }}
COMMIT_SHA: ${{ gitea.sha }}
run: |
set -euo pipefail
test -n "$QUAY_USERNAME" && test -n "$QUAY_TOKEN"
source_dir="$RUNNER_TEMP/loops-source"
git clone --depth 1 --branch "$APP_VERSION" https://github.com/joinloops/loops-server.git "$source_dir"
git -C "$source_dir" apply "$GITHUB_WORKSPACE/patches/loops-frontend.patch"
docker build --pull --load \
--label "org.opencontainers.image.revision=$COMMIT_SHA" \
--label "org.opencontainers.image.version=$APP_VERSION" \
--label "org.opencontainers.image.source=https://github.com/joinloops/loops-server" \
--tag "registry.brunner.ninja/feedc0de/loops:$APP_VERSION" \
"$source_dir"
docker run --rm --entrypoint php "registry.brunner.ninja/feedc0de/loops:$APP_VERSION" -r '
if (PHP_VERSION_ID < 80512) { fwrite(STDERR, "PHP security floor 8.5.12 not met\\n"); exit(1); }
echo PHP_VERSION, "\n";
'
docker run --rm --entrypoint ffmpeg "registry.brunner.ninja/feedc0de/loops:$APP_VERSION" -version | head -n 1 | grep -F 'ffmpeg version 9.0.2'
docker run --rm --entrypoint sh "registry.brunner.ninja/feedc0de/loops:$APP_VERSION" -ec 'grep -R -l "recommended-feed" /var/www/html/public/build/assets >/dev/null; grep -R -l "fyfeed" /var/www/html/public/build/assets >/dev/null'
printf '%s' "$QUAY_TOKEN" | docker login registry.brunner.ninja --username "$QUAY_USERNAME" --password-stdin
docker push "registry.brunner.ninja/feedc0de/loops:$APP_VERSION"
- name: Package and upload
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 --destination "$RUNNER_TEMP" --version "$CHART_VERSION"
curl --fail --silent --show-error --user "$PACKAGE_USERNAME:$PACKAGE_TOKEN" \
--request POST --upload-file "$RUNNER_TEMP/loops-$CHART_VERSION.tgz" \
https://code.brunner.ninja/api/packages/feedc0de/helm/api/charts
- name: Confirm current main
env:
COMMIT_SHA: ${{ gitea.sha }}
run: |
git fetch --no-tags origin main
test "$(git rev-parse FETCH_HEAD)" = "$COMMIT_SHA"
- uses: actions/checkout@v4
with:
repository: feedc0de/homelab-gitops
ref: main
token: ${{ secrets.GITOPS_TOKEN }}
path: homelab-gitops
- name: Promote exact chart
working-directory: homelab-gitops
run: |
set -euo pipefail
./scripts/update-chart-version.sh loops "$CHART_VERSION"
git config user.name feedc0de
git config user.email feedc0de@users.noreply.code.brunner.ninja
git add bootstrap/loops.yaml
if git diff --cached --quiet; then exit 0; fi
git commit -m "Deploy loops chart $CHART_VERSION"
for attempt in 1 2 3; do
git push origin HEAD:main && exit 0
test "$attempt" = 3 && exit 1
git fetch origin main
git rebase origin/main
done