From 6b2d7ddf2f823e63dc80f8fd43d1679cc9bff1a7 Mon Sep 17 00:00:00 2001 From: Catalan Lover Date: Sun, 3 May 2026 07:51:23 +0200 Subject: [PATCH] Rework Self Build Logic to integrate review feedback. --- .../tasks/setup_install.yml | 8 +++++--- roles/custom/matrix-bot-draupnir/tasks/setup_install.yml | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/roles/custom/matrix-appservice-draupnir-for-all/tasks/setup_install.yml b/roles/custom/matrix-appservice-draupnir-for-all/tasks/setup_install.yml index ba01a0b81..95a5f1fa4 100644 --- a/roles/custom/matrix-appservice-draupnir-for-all/tasks/setup_install.yml +++ b/roles/custom/matrix-appservice-draupnir-for-all/tasks/setup_install.yml @@ -48,14 +48,16 @@ - name: Ensure Draupnir Docker image is built # Using docker_image_build with BuildKit for modern, efficient builds. - # docker_image_build automatically rebuilds when the Dockerfile or build context changes. - # The git_pull_results will show if the source was updated above. + # Rebuild when the git checkout advanced to a new commit; otherwise keep the build idempotent. + # Technically the idempotency of rebuilds is more that if a build has already been executed for that name:tag + # then we wont rebuild while in idempotent mode even if git moved. Thats what the force rebuild logic is for. community.docker.docker_image_build: name: "{{ matrix_appservice_draupnir_for_all_container_image }}" dockerfile: Dockerfile path: "{{ matrix_appservice_draupnir_for_all_container_src_files_path }}" pull: true - when: "matrix_appservice_draupnir_for_all_container_image_self_build | bool and matrix_appservice_draupnir_for_all_git_pull_results.changed" + rebuild: "{{ 'always' if matrix_appservice_draupnir_for_all_git_pull_results.changed | bool else 'never' }}" + when: "matrix_appservice_draupnir_for_all_container_image_self_build | bool" register: matrix_appservice_draupnir_for_all_container_image_build_result - name: Ensure matrix-appservice-draupnir-for-all appservice config installed diff --git a/roles/custom/matrix-bot-draupnir/tasks/setup_install.yml b/roles/custom/matrix-bot-draupnir/tasks/setup_install.yml index 8ddb58af5..5f173d3af 100644 --- a/roles/custom/matrix-bot-draupnir/tasks/setup_install.yml +++ b/roles/custom/matrix-bot-draupnir/tasks/setup_install.yml @@ -60,14 +60,16 @@ - name: Ensure Draupnir Docker image is built # Using docker_image_build with BuildKit for modern, efficient builds. - # docker_image_build automatically rebuilds when the Dockerfile or build context changes. - # The git_pull_results will show if the source was updated above. + # Rebuild when the git checkout advanced to a new commit; otherwise keep the build idempotent. + # Technically the idempotency of rebuilds is more that if a build has already been executed for that name:tag + # then we wont rebuild while in idempotent mode even if git moved. Thats what the force rebuild logic is for. community.docker.docker_image_build: name: "{{ matrix_bot_draupnir_container_image }}" dockerfile: Dockerfile path: "{{ matrix_bot_draupnir_container_src_files_path }}" pull: true - when: "matrix_bot_draupnir_container_image_self_build | bool and matrix_bot_draupnir_git_pull_results.changed" + rebuild: "{{ 'always' if matrix_bot_draupnir_git_pull_results.changed | bool else 'never' }}" + when: "matrix_bot_draupnir_container_image_self_build | bool" register: matrix_bot_draupnir_container_image_build_result - name: Ensure matrix-bot-draupnir config installed