fix: move image cleanup to post-build job after all builds complete
This commit is contained in:
parent
d0b768d602
commit
758f0699ff
1 changed files with 32 additions and 16 deletions
|
|
@ -224,22 +224,6 @@ jobs:
|
|||
.
|
||||
fi
|
||||
|
||||
- name: Prune old image tags (keep latest 1 SHA)
|
||||
if: success()
|
||||
continue-on-error: true
|
||||
env:
|
||||
REGISTRY_HOST: ${{ secrets.REGISTRY_HOSTPORT }}
|
||||
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
|
||||
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
python3 .forgejo/scripts/registry_prune.py \
|
||||
--registry "$REGISTRY_HOST" \
|
||||
--repo "nxtgauge-rust-${{ matrix.service }}" \
|
||||
--username "$REGISTRY_USERNAME" \
|
||||
--password "$REGISTRY_PASSWORD" \
|
||||
--keep 1
|
||||
|
||||
- name: Update GitOps and trigger deployment
|
||||
if: always()
|
||||
continue-on-error: true
|
||||
|
|
@ -274,3 +258,35 @@ jobs:
|
|||
--message "chore: deploy ${{ matrix.service }}@${SHA}"
|
||||
|
||||
rm -rf "$GITEOPS_DIR"
|
||||
|
||||
cleanup-after-build:
|
||||
needs: build
|
||||
if: always() && needs.build.result == 'success'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Cleanup old image tags (after all builds complete)
|
||||
continue-on-error: true
|
||||
env:
|
||||
REGISTRY_HOST: ${{ secrets.REGISTRY_HOSTPORT }}
|
||||
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
|
||||
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
SERVICES_CSV: ${{ needs.build.outputs.services_csv || 'gateway,users,companies,jobs,leads,job-seekers,customers,payments,employees,photographers,makeup-artists,tutors,developers,video-editors,graphic-designers,social-media-managers,fitness-trainers,catering-services,ugc-content-creators,cron' }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
echo "Starting post-build cleanup for services: $SERVICES_CSV"
|
||||
|
||||
IFS=',' read -ra SERVICES <<< "$SERVICES_CSV"
|
||||
for service in "${SERVICES[@]}"; do
|
||||
echo "Pruning old images for nxtgauge-rust-$service..."
|
||||
python3 .forgejo/scripts/registry_prune.py \
|
||||
--registry "$REGISTRY_HOST" \
|
||||
--repo "nxtgauge-rust-$service" \
|
||||
--username "$REGISTRY_USERNAME" \
|
||||
--password "$REGISTRY_PASSWORD" \
|
||||
--keep 3 || echo "Warning: Failed to prune $service (continuing)"
|
||||
done
|
||||
|
||||
echo "Post-build cleanup completed"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue