From 4e3096b8b63d5887a964e2d2b9e111aa19974694 Mon Sep 17 00:00:00 2001 From: Pieter van Staden <pieter@bob.co.za> Date: Mon, 5 May 2025 14:40:05 +0200 Subject: [PATCH 1/4] INFRASTRUCTURE :: Update the check to make sure the tag is created from the prod branch --- .gitlab-ci.yml | 12 +++++++----- composer.json | 2 +- etc/module.xml | 2 +- package.json | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7862434..f5a6661 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -35,12 +35,14 @@ tag_deploy: - export AWS_SECRET_ACCESS_KEY # Fetch the prod branch - git fetch origin prod - # Check if the tagged commit is from the prod branch using merge-base - - if git merge-base --is-ancestor "${CI_COMMIT_SHA}" origin/prod; then - echo "Tag ${CI_COMMIT_TAG} is from the prod branch."; - else - echo "Tag ${CI_COMMIT_TAG} is not from the prod branch."; + # Get the current branch or tag pointing ref + - TAG_BRANCH=$(git for-each-ref --format='%(refname:short)' --contains $CI_COMMIT_SHA refs/heads/ | grep "^prod$" || echo "") + - echo "Current branches containing this commit: $(git for-each-ref --format='%(refname:short)' --contains $CI_COMMIT_SHA refs/heads/)" + - if [ -z "$TAG_BRANCH" ]; then + echo "Tag ${CI_COMMIT_TAG} was not created on the prod branch."; exit 1; + else + echo "Tag ${CI_COMMIT_TAG} was created on the prod branch."; fi script: - "TAG_ARCHIVE_URL=https://gitlab.bob.co.za/bob-public-utils/bobgo-magento-extension/-/archive/${CI_COMMIT_TAG}/bobgo-magento-extension-${CI_COMMIT_TAG}.zip" diff --git a/composer.json b/composer.json index 4d5f670..bc33c00 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "bobgo/bobgo-magento-extension", "description": "Smart shipping and order management solution in South Africa", "type": "magento2-module", - "version": "1.0.52", + "version": "1.0.53", "authors": [ { "name": "Bob Go", diff --git a/etc/module.xml b/etc/module.xml index 89ebeab..c6469b1 100644 --- a/etc/module.xml +++ b/etc/module.xml @@ -7,7 +7,7 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> - <module name="BobGroup_BobGo" setup_version="1.0.52"> + <module name="BobGroup_BobGo" setup_version="1.0.53"> <sequence> <module name="Magento_Webapi"/> <module name="Magento_Catalog"/> diff --git a/package.json b/package.json index 0429860..ad01470 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "bobgo-magento-plugin", "description": "Bob Go magento plugin", - "version": "1.0.52", + "version": "1.0.53", "license": "GPL-2.0-or-later", "scripts": { "prepare": "husky install", -- GitLab From 6d8a008f1c71d8b0383f39a99c36a667553a88e4 Mon Sep 17 00:00:00 2001 From: Pieter van Staden <pieter@bob.co.za> Date: Mon, 5 May 2025 14:42:59 +0200 Subject: [PATCH 2/4] INFRASTRUCTURE :: Update the check to make sure the tag is created from the prod branch --- .gitlab-ci.yml | 9 +-------- composer.json | 2 +- etc/module.xml | 2 +- package.json | 2 +- 4 files changed, 4 insertions(+), 11 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f5a6661..a2c738e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -33,17 +33,10 @@ tag_deploy: - AWS_SECRET_ACCESS_KEY=$(eval echo -e "\$$AWS_SECRET_ACCESS_KEY_KEY") - export AWS_ACCESS_KEY_ID - export AWS_SECRET_ACCESS_KEY - # Fetch the prod branch - git fetch origin prod - # Get the current branch or tag pointing ref - TAG_BRANCH=$(git for-each-ref --format='%(refname:short)' --contains $CI_COMMIT_SHA refs/heads/ | grep "^prod$" || echo "") - echo "Current branches containing this commit: $(git for-each-ref --format='%(refname:short)' --contains $CI_COMMIT_SHA refs/heads/)" - - if [ -z "$TAG_BRANCH" ]; then - echo "Tag ${CI_COMMIT_TAG} was not created on the prod branch."; - exit 1; - else - echo "Tag ${CI_COMMIT_TAG} was created on the prod branch."; - fi + - if [ -z "$TAG_BRANCH" ]; then echo "Tag ${CI_COMMIT_TAG} was not created on the prod branch."; exit 1; else echo "Tag ${CI_COMMIT_TAG} was created on the prod branch."; fi script: - "TAG_ARCHIVE_URL=https://gitlab.bob.co.za/bob-public-utils/bobgo-magento-extension/-/archive/${CI_COMMIT_TAG}/bobgo-magento-extension-${CI_COMMIT_TAG}.zip" - curl -o bobgo-magento-extension-${CI_COMMIT_TAG}.zip "$TAG_ARCHIVE_URL" diff --git a/composer.json b/composer.json index bc33c00..4e3389c 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "bobgo/bobgo-magento-extension", "description": "Smart shipping and order management solution in South Africa", "type": "magento2-module", - "version": "1.0.53", + "version": "1.0.54", "authors": [ { "name": "Bob Go", diff --git a/etc/module.xml b/etc/module.xml index c6469b1..511b611 100644 --- a/etc/module.xml +++ b/etc/module.xml @@ -7,7 +7,7 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> - <module name="BobGroup_BobGo" setup_version="1.0.53"> + <module name="BobGroup_BobGo" setup_version="1.0.54"> <sequence> <module name="Magento_Webapi"/> <module name="Magento_Catalog"/> diff --git a/package.json b/package.json index ad01470..47e8b0e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "bobgo-magento-plugin", "description": "Bob Go magento plugin", - "version": "1.0.53", + "version": "1.0.54", "license": "GPL-2.0-or-later", "scripts": { "prepare": "husky install", -- GitLab From b5b3f5e41fb587bbf52ceff1abf3cec13de18f1f Mon Sep 17 00:00:00 2001 From: Pieter van Staden <pieter@bob.co.za> Date: Mon, 5 May 2025 14:46:13 +0200 Subject: [PATCH 3/4] INFRASTRUCTURE :: Update the check to make sure the tag is created from the prod branch --- .gitlab-ci.yml | 8 +++++++- composer.json | 2 +- etc/module.xml | 2 +- package.json | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a2c738e..f8e0203 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -36,7 +36,13 @@ tag_deploy: - git fetch origin prod - TAG_BRANCH=$(git for-each-ref --format='%(refname:short)' --contains $CI_COMMIT_SHA refs/heads/ | grep "^prod$" || echo "") - echo "Current branches containing this commit: $(git for-each-ref --format='%(refname:short)' --contains $CI_COMMIT_SHA refs/heads/)" - - if [ -z "$TAG_BRANCH" ]; then echo "Tag ${CI_COMMIT_TAG} was not created on the prod branch."; exit 1; else echo "Tag ${CI_COMMIT_TAG} was created on the prod branch."; fi + - | + if [ -z "$TAG_BRANCH" ]; then + echo "Tag ${CI_COMMIT_TAG} was not created on the prod branch." + exit 1 + else + echo "Tag ${CI_COMMIT_TAG} was created on the prod branch." + fi script: - "TAG_ARCHIVE_URL=https://gitlab.bob.co.za/bob-public-utils/bobgo-magento-extension/-/archive/${CI_COMMIT_TAG}/bobgo-magento-extension-${CI_COMMIT_TAG}.zip" - curl -o bobgo-magento-extension-${CI_COMMIT_TAG}.zip "$TAG_ARCHIVE_URL" diff --git a/composer.json b/composer.json index 4e3389c..d4423e2 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "bobgo/bobgo-magento-extension", "description": "Smart shipping and order management solution in South Africa", "type": "magento2-module", - "version": "1.0.54", + "version": "1.0.55", "authors": [ { "name": "Bob Go", diff --git a/etc/module.xml b/etc/module.xml index 511b611..1360275 100644 --- a/etc/module.xml +++ b/etc/module.xml @@ -7,7 +7,7 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> - <module name="BobGroup_BobGo" setup_version="1.0.54"> + <module name="BobGroup_BobGo" setup_version="1.0.55"> <sequence> <module name="Magento_Webapi"/> <module name="Magento_Catalog"/> diff --git a/package.json b/package.json index 47e8b0e..e611546 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "bobgo-magento-plugin", "description": "Bob Go magento plugin", - "version": "1.0.54", + "version": "1.0.55", "license": "GPL-2.0-or-later", "scripts": { "prepare": "husky install", -- GitLab From 6562dc4daf2e27f0dd230eb64f226b8d9feb3645 Mon Sep 17 00:00:00 2001 From: Pieter van Staden <pieter@bob.co.za> Date: Mon, 5 May 2025 14:54:30 +0200 Subject: [PATCH 4/4] INFRASTRUCTURE :: Update the check to make sure the tag is created from the prod branch --- .gitlab-ci.yml | 17 ++++++++++------- composer.json | 2 +- etc/module.xml | 2 +- package.json | 2 +- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f8e0203..a8ea2ed 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -33,15 +33,18 @@ tag_deploy: - AWS_SECRET_ACCESS_KEY=$(eval echo -e "\$$AWS_SECRET_ACCESS_KEY_KEY") - export AWS_ACCESS_KEY_ID - export AWS_SECRET_ACCESS_KEY - - git fetch origin prod - - TAG_BRANCH=$(git for-each-ref --format='%(refname:short)' --contains $CI_COMMIT_SHA refs/heads/ | grep "^prod$" || echo "") - - echo "Current branches containing this commit: $(git for-each-ref --format='%(refname:short)' --contains $CI_COMMIT_SHA refs/heads/)" + # Ensure all branches and tags are fetched + - echo "Fetching all branches and tags..." + - git fetch --all + - git fetch --tags + # Verify the branch of origin for the tag - | - if [ -z "$TAG_BRANCH" ]; then - echo "Tag ${CI_COMMIT_TAG} was not created on the prod branch." - exit 1 + branch=$(git branch -r --contains "${CI_COMMIT_SHA}" | grep -v 'tags/' | awk '{print $1}' | sed 's/origin\///' | head -n 1) + if [ "$branch" = "prod" ]; then + echo "Tag ${CI_COMMIT_TAG} is from the prod branch."; else - echo "Tag ${CI_COMMIT_TAG} was created on the prod branch." + echo "Tag ${CI_COMMIT_TAG} is not from the prod branch. It was created from the '${branch}' branch."; + exit 1; fi script: - "TAG_ARCHIVE_URL=https://gitlab.bob.co.za/bob-public-utils/bobgo-magento-extension/-/archive/${CI_COMMIT_TAG}/bobgo-magento-extension-${CI_COMMIT_TAG}.zip" diff --git a/composer.json b/composer.json index d4423e2..ffbe058 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "bobgo/bobgo-magento-extension", "description": "Smart shipping and order management solution in South Africa", "type": "magento2-module", - "version": "1.0.55", + "version": "1.0.56", "authors": [ { "name": "Bob Go", diff --git a/etc/module.xml b/etc/module.xml index 1360275..e6f0120 100644 --- a/etc/module.xml +++ b/etc/module.xml @@ -7,7 +7,7 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> - <module name="BobGroup_BobGo" setup_version="1.0.55"> + <module name="BobGroup_BobGo" setup_version="1.0.56"> <sequence> <module name="Magento_Webapi"/> <module name="Magento_Catalog"/> diff --git a/package.json b/package.json index e611546..3d9d7da 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "bobgo-magento-plugin", "description": "Bob Go magento plugin", - "version": "1.0.55", + "version": "1.0.56", "license": "GPL-2.0-or-later", "scripts": { "prepare": "husky install", -- GitLab