Fase 3c (code, nog niet uitgerold): foto's altijd in de bibliotheektabel, HeroImages-migratie met controle, schakelaars en hulpmiddelen weg
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -15,26 +15,6 @@ on:
|
||||
description: 'Deploy ASF test (Andrea Slop Fotografie)'
|
||||
type: boolean
|
||||
default: false
|
||||
media_library_copy:
|
||||
description: 'Media library copy on the TEST deploys (Media__Library__CopyOnStartup in shared/env): unchanged, on or off'
|
||||
type: choice
|
||||
options: [unchanged, 'on', 'off']
|
||||
default: unchanged
|
||||
media_library_dual_write:
|
||||
description: 'Media library write-through on the TEST deploys (Media__Library__DualWrite in shared/env): unchanged, on or off'
|
||||
type: choice
|
||||
options: [unchanged, 'on', 'off']
|
||||
default: unchanged
|
||||
media_library_read:
|
||||
description: 'Media library read switch on the TEST deploys (Media__Library__ReadFromLibrary in shared/env): unchanged, off, compare or on'
|
||||
type: choice
|
||||
options: [unchanged, 'off', compare, 'on']
|
||||
default: unchanged
|
||||
media_library_hero_photos:
|
||||
description: 'Hero photos in the media library on the TEST deploys (Media__Library__HeroPhotosInLibrary in shared/env): unchanged, on or off. Needs the copy and the library check first.'
|
||||
type: choice
|
||||
options: [unchanged, 'on', 'off']
|
||||
default: unchanged
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened]
|
||||
push:
|
||||
@@ -575,10 +555,6 @@ jobs:
|
||||
service_name: ${{ vars.SERVICE_NAME_TEST }}
|
||||
health_check_url: ${{ vars.HEALTH_CHECK_URL_TEST }}
|
||||
run_db_backup: false
|
||||
media_library_copy: ${{ github.event.inputs.media_library_copy || 'unchanged' }}
|
||||
media_library_dual_write: ${{ github.event.inputs.media_library_dual_write || 'unchanged' }}
|
||||
media_library_read: ${{ github.event.inputs.media_library_read || 'unchanged' }}
|
||||
media_library_hero_photos: ${{ github.event.inputs.media_library_hero_photos || 'unchanged' }}
|
||||
|
||||
# Production deploy ONLY on an explicit workflow_dispatch run with deploy_sls_production checked, and
|
||||
# only when that run is on a release/* branch (same rule as ASF) — never reachable from a plain push
|
||||
@@ -706,10 +682,6 @@ jobs:
|
||||
service_name: ${{ vars.SERVICE_NAME_ASF_TEST }}
|
||||
health_check_url: ${{ vars.HEALTH_CHECK_URL_ASF_TEST }}
|
||||
run_db_backup: false
|
||||
media_library_copy: ${{ github.event.inputs.media_library_copy || 'unchanged' }}
|
||||
media_library_dual_write: ${{ github.event.inputs.media_library_dual_write || 'unchanged' }}
|
||||
media_library_read: ${{ github.event.inputs.media_library_read || 'unchanged' }}
|
||||
media_library_hero_photos: ${{ github.event.inputs.media_library_hero_photos || 'unchanged' }}
|
||||
|
||||
# --- Smoke tests of the deployed compositions (anonymous requests, see scripts/smoke-site.sh) ---
|
||||
# The CI tests the master CMS; this is the check that the composition of each site that was just deployed to test
|
||||
|
||||
@@ -37,26 +37,6 @@ on:
|
||||
required: false
|
||||
type: string
|
||||
default: scp
|
||||
media_library_copy:
|
||||
description: 'unchanged | on | off: sets Media__Library__CopyOnStartup in shared/env before the restart. TEST only, never production.'
|
||||
required: false
|
||||
type: string
|
||||
default: unchanged
|
||||
media_library_dual_write:
|
||||
description: 'unchanged | on | off: sets Media__Library__DualWrite (the write-through of phase 2) in shared/env before the restart. TEST only, never production.'
|
||||
required: false
|
||||
type: string
|
||||
default: unchanged
|
||||
media_library_read:
|
||||
description: 'unchanged | off | compare | on: sets Media__Library__ReadFromLibrary (the read switch of phase 2) in shared/env before the restart. TEST only, never production.'
|
||||
required: false
|
||||
type: string
|
||||
default: unchanged
|
||||
media_library_hero_photos:
|
||||
description: 'unchanged | on | off: sets Media__Library__HeroPhotosInLibrary (phase 3b: the hero photos live in the library table) in shared/env before the restart. TEST only, never production.'
|
||||
required: false
|
||||
type: string
|
||||
default: unchanged
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
@@ -231,119 +211,6 @@ jobs:
|
||||
ln -sf \"../../shared/modules/\$name\" \"$RELEASE_DIR/\$name\"; \
|
||||
done"
|
||||
|
||||
# The media library copy switch (migration plan of the media library, decision 13): the application reads
|
||||
# Media__Library__CopyOnStartup from the host environment file shared/env (D-16). The deploy account can edit that file,
|
||||
# nobody else needs a shell on the host. Only this ONE key is touched (nothing else of the file is read or printed, the
|
||||
# file holds secrets), only on a test environment, and only with a value that is exactly on, off or unchanged.
|
||||
# `on` makes the next start copy the photos into the library's tables and verify the copy (log line
|
||||
# "Media library copy verified: N photos and M uses"); `off` removes the key again (the default is off).
|
||||
- name: Set the media library copy switch (test only)
|
||||
if: inputs.media_library_copy != 'unchanged'
|
||||
env:
|
||||
SSH_USER: ${{ secrets.PI_MAIN_USERNAME }}
|
||||
SSH_PASS: ${{ secrets.PI_MAIN_PASSWORD }}
|
||||
SSH_PORT: ${{ secrets.PI_MAIN_PORT }}
|
||||
SSH_HOST: ${{ secrets.PI_MAIN_ADDRESS }}
|
||||
run: |
|
||||
MODE="${{ inputs.media_library_copy }}"
|
||||
if [ "${{ inputs.environment }}" != "test" ]; then
|
||||
echo "The media library copy switch is for the test environment only (environment: ${{ inputs.environment }})." >&2
|
||||
exit 1
|
||||
fi
|
||||
if [ "$MODE" != "on" ] && [ "$MODE" != "off" ]; then
|
||||
echo "media_library_copy must be unchanged, on or off (got: $MODE)." >&2
|
||||
exit 1
|
||||
fi
|
||||
ENV_FILE="${{ inputs.deploy_path }}/shared/env"
|
||||
if [ "$MODE" = "on" ]; then
|
||||
rssh "touch $ENV_FILE && sed -i '/^Media__Library__CopyOnStartup=/d' $ENV_FILE && echo 'Media__Library__CopyOnStartup=true' >> $ENV_FILE"
|
||||
else
|
||||
rssh "touch $ENV_FILE && sed -i '/^Media__Library__CopyOnStartup=/d' $ENV_FILE"
|
||||
fi
|
||||
echo "Media__Library__CopyOnStartup is now: $(rssh "grep '^Media__Library__CopyOnStartup=' $ENV_FILE || echo '(not set = off)'")"
|
||||
|
||||
# The write-through switch of phase 2 (same rules as the copy switch above: only this one key of shared/env, only on test,
|
||||
# only on, off or unchanged). `on` makes every change of the hero also land in the library's tables.
|
||||
- name: Set the media library write-through switch (test only)
|
||||
if: inputs.media_library_dual_write != 'unchanged'
|
||||
env:
|
||||
SSH_USER: ${{ secrets.PI_MAIN_USERNAME }}
|
||||
SSH_PASS: ${{ secrets.PI_MAIN_PASSWORD }}
|
||||
SSH_PORT: ${{ secrets.PI_MAIN_PORT }}
|
||||
SSH_HOST: ${{ secrets.PI_MAIN_ADDRESS }}
|
||||
run: |
|
||||
MODE="${{ inputs.media_library_dual_write }}"
|
||||
if [ "${{ inputs.environment }}" != "test" ]; then
|
||||
echo "The media library write-through switch is for the test environment only (environment: ${{ inputs.environment }})." >&2
|
||||
exit 1
|
||||
fi
|
||||
if [ "$MODE" != "on" ] && [ "$MODE" != "off" ]; then
|
||||
echo "media_library_dual_write must be unchanged, on or off (got: $MODE)." >&2
|
||||
exit 1
|
||||
fi
|
||||
ENV_FILE="${{ inputs.deploy_path }}/shared/env"
|
||||
if [ "$MODE" = "on" ]; then
|
||||
rssh "touch $ENV_FILE && sed -i '/^Media__Library__DualWrite=/d' $ENV_FILE && echo 'Media__Library__DualWrite=true' >> $ENV_FILE"
|
||||
else
|
||||
rssh "touch $ENV_FILE && sed -i '/^Media__Library__DualWrite=/d' $ENV_FILE"
|
||||
fi
|
||||
echo "Media__Library__DualWrite is now: $(rssh "grep '^Media__Library__DualWrite=' $ENV_FILE || echo '(not set = off)'")"
|
||||
|
||||
# The read switch of phase 2 (same rules as the switches above): compare = the library tables are read too and differences are
|
||||
# logged and shown by GET media-library/read-check; on = the library screen reads the library tables (needs the write-through).
|
||||
- name: Set the media library read switch (test only)
|
||||
if: inputs.media_library_read != 'unchanged'
|
||||
env:
|
||||
SSH_USER: ${{ secrets.PI_MAIN_USERNAME }}
|
||||
SSH_PASS: ${{ secrets.PI_MAIN_PASSWORD }}
|
||||
SSH_PORT: ${{ secrets.PI_MAIN_PORT }}
|
||||
SSH_HOST: ${{ secrets.PI_MAIN_ADDRESS }}
|
||||
run: |
|
||||
MODE="${{ inputs.media_library_read }}"
|
||||
if [ "${{ inputs.environment }}" != "test" ]; then
|
||||
echo "The media library read switch is for the test environment only (environment: ${{ inputs.environment }})." >&2
|
||||
exit 1
|
||||
fi
|
||||
if [ "$MODE" != "on" ] && [ "$MODE" != "off" ] && [ "$MODE" != "compare" ]; then
|
||||
echo "media_library_read must be unchanged, off, compare or on (got: $MODE)." >&2
|
||||
exit 1
|
||||
fi
|
||||
ENV_FILE="${{ inputs.deploy_path }}/shared/env"
|
||||
if [ "$MODE" = "off" ]; then
|
||||
rssh "touch $ENV_FILE && sed -i '/^Media__Library__ReadFromLibrary=/d' $ENV_FILE"
|
||||
else
|
||||
rssh "touch $ENV_FILE && sed -i '/^Media__Library__ReadFromLibrary=/d' $ENV_FILE && echo 'Media__Library__ReadFromLibrary=$MODE' >> $ENV_FILE"
|
||||
fi
|
||||
echo "Media__Library__ReadFromLibrary is now: $(rssh "grep '^Media__Library__ReadFromLibrary=' $ENV_FILE || echo '(not set = off)'")"
|
||||
|
||||
# The hero-photos storage switch of phase 3b (same rules as the switches above). `on` makes the hero keep its photos in the
|
||||
# library's MediaAssets table (HeroImages stays a copy so it can go back); the application REFUSES to start when the library
|
||||
# does not yet hold every hero photo, so run the copy first and check it with the library check.
|
||||
- name: Set the media library hero photos switch (test only)
|
||||
if: inputs.media_library_hero_photos != 'unchanged'
|
||||
env:
|
||||
SSH_USER: ${{ secrets.PI_MAIN_USERNAME }}
|
||||
SSH_PASS: ${{ secrets.PI_MAIN_PASSWORD }}
|
||||
SSH_PORT: ${{ secrets.PI_MAIN_PORT }}
|
||||
SSH_HOST: ${{ secrets.PI_MAIN_ADDRESS }}
|
||||
run: |
|
||||
MODE="${{ inputs.media_library_hero_photos }}"
|
||||
if [ "${{ inputs.environment }}" != "test" ]; then
|
||||
echo "The hero photos switch is for the test environment only (environment: ${{ inputs.environment }})." >&2
|
||||
exit 1
|
||||
fi
|
||||
if [ "$MODE" != "on" ] && [ "$MODE" != "off" ]; then
|
||||
echo "media_library_hero_photos must be unchanged, on or off (got: $MODE)." >&2
|
||||
exit 1
|
||||
fi
|
||||
ENV_FILE="${{ inputs.deploy_path }}/shared/env"
|
||||
if [ "$MODE" = "on" ]; then
|
||||
rssh "touch $ENV_FILE && sed -i '/^Media__Library__HeroPhotosInLibrary=/d' $ENV_FILE && echo 'Media__Library__HeroPhotosInLibrary=true' >> $ENV_FILE"
|
||||
else
|
||||
rssh "touch $ENV_FILE && sed -i '/^Media__Library__HeroPhotosInLibrary=/d' $ENV_FILE"
|
||||
fi
|
||||
echo "Media__Library__HeroPhotosInLibrary is now: $(rssh "grep '^Media__Library__HeroPhotosInLibrary=' $ENV_FILE || echo '(not set = off)'")"
|
||||
|
||||
# Atomic release switch (FR-06, D-27): `ln -sfn` replaces the `current` symlink target in a
|
||||
# single filesystem operation, so there is no moment where `current` points at a half-written
|
||||
# directory. The process is then restarted so it picks up the new assemblies — a running .NET
|
||||
@@ -360,20 +227,6 @@ jobs:
|
||||
"ln -sfn $RELEASE_DIR ${{ inputs.deploy_path }}/current && \
|
||||
systemctl --user restart ${{ inputs.service_name }}"
|
||||
|
||||
# After a restart with the copy on, show the verification line of the copy in this run's log (the journal of the user
|
||||
# service), so nobody needs a shell on the host to see "Media library copy verified: N photos and M uses".
|
||||
- name: Report the media library copy (test only)
|
||||
if: inputs.media_library_copy == 'on'
|
||||
env:
|
||||
SSH_USER: ${{ secrets.PI_MAIN_USERNAME }}
|
||||
SSH_PASS: ${{ secrets.PI_MAIN_PASSWORD }}
|
||||
SSH_PORT: ${{ secrets.PI_MAIN_PORT }}
|
||||
SSH_HOST: ${{ secrets.PI_MAIN_ADDRESS }}
|
||||
run: |
|
||||
sleep 20
|
||||
rssh "journalctl --user -u ${{ inputs.service_name }} --since '-10 min' --no-pager 2>/dev/null | grep -E 'Media library copy|media library copy' | tail -5 || true"
|
||||
echo "Look for 'Media library copy verified: N photos and M uses'. An error line means the copy was rolled back and nothing was copied."
|
||||
|
||||
# Verifies the restart actually produced a healthy process before this run is allowed to
|
||||
# report success. Retries absorb process-startup time, which is about 10 seconds normally but
|
||||
# 30 seconds or more when the host is busy (a migration step, two services restarting at once
|
||||
|
||||
Reference in New Issue
Block a user