Avoid running promotion jobs unnecessarily
diff --git a/.github/workflows/promote.yml b/.github/workflows/promote.yml
index f4aa1f9..2955624 100644
--- a/.github/workflows/promote.yml
+++ b/.github/workflows/promote.yml
@@ -10,7 +10,7 @@
     steps:
       - uses: actions/checkout@v3.0.2
       - id: set-strategy
-        run: echo "::set-output name=strategy::$(./ci/build-image-strategy all)"
+        run: echo "::set-output name=strategy::$(./ci/build-image-strategy promote)"
     outputs:
       strategy: ${{ steps.set-strategy.outputs.strategy }}
 
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index c2408ec..e831222 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -8,7 +8,7 @@
     steps:
       - uses: actions/checkout@v3.0.2
       - id: set-strategy
-        run: echo "::set-output name=strategy::$(./ci/build-image-strategy)"
+        run: echo "::set-output name=strategy::$(./ci/build-image-strategy build)"
     outputs:
       strategy: ${{ steps.set-strategy.outputs.strategy }}
 
diff --git a/ci/build-image-strategy b/ci/build-image-strategy
index 495bced..954dbde 100755
--- a/ci/build-image-strategy
+++ b/ci/build-image-strategy
@@ -12,15 +12,42 @@
 
 DATA = {}
 
-if len(sys.argv) > 1 and sys.argv[1] == "all":
-    DATA = {
-        "fail-fast": False,
-        "matrix": {
-            "release": RELEASES,
-            "project": PROJECTS,
-        },
-    }
-else:
+if sys.argv[1] == "promote":
+    for release in RELEASES:
+        for project in PROJECTS:
+            ref = (
+                open(f"images/openstack/projects/{project}/{release}/ref", "r")
+                .read()
+                .strip()
+            )
+
+            r = requests.get(
+                f"https://quay.io/api/v1/repository/vexxhost/{project}/tag/?specificTag={release}"
+            )
+            tags = r.json().get("tags")
+            if len(tags) == 0:
+                MATRIX += [
+                    {
+                        "release": release,
+                        "project": project,
+                    }
+                ]
+            sha1_manifest_digest = tags[0].get("manifest_digest")
+
+            r = requests.get(
+                f"https://quay.io/api/v1/repository/vexxhost/{project}/tag/?specificTag={ref}"
+            )
+            tags = r.json().get("tags")
+            release_manifest_digest = tags[0].get("manifest_digest")
+
+            if release_manifest_digest != sha1_manifest_digest:
+                MATRIX += [
+                    {
+                        "release": release,
+                        "project": project,
+                    }
+                ]
+elif sys.argv[1] == "build":
     for release in RELEASES:
         for project in PROJECTS:
             ref = (
@@ -41,12 +68,12 @@
                     }
                 ]
 
-    if len(MATRIX) != 0:
-        DATA = {
-            "fail-fast": False,
-            "matrix": {
-                "include": MATRIX,
-            },
-        }
 
+if len(MATRIX) != 0:
+    DATA = {
+        "fail-fast": False,
+        "matrix": {
+            "include": MATRIX,
+        },
+    }
 json.dump(DATA, sys.stdout, separators=(",", ":"))