From b297cbd4ed0eaca8d000349361f50fd861404b30 Mon Sep 17 00:00:00 2001 From: Aaron Date: Tue, 17 Jan 2023 15:16:00 +0100 Subject: [PATCH 01/14] allow latest tag --- action.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/action.yaml b/action.yaml index 74ff6ca..a91e5bf 100644 --- a/action.yaml +++ b/action.yaml @@ -201,7 +201,11 @@ runs: - name: 'Docker push to Artifacts Registry' run: | ARRAY_CONTAINERS=(${CONTAINER_LIST}) - for CONTAINER in "${ARRAY_CONTAINERS[@]}"; do docker push ${REGISTRY}${CONTAINER}:${TAG_IMG}; done + for CONTAINER in "${ARRAY_CONTAINERS[@]}" + do + docker tag ${REGISTRY}${CONTAINER}:latest ${REGISTRY}${CONTAINER}:${TAG_IMG} + docker push ${REGISTRY}${CONTAINER}:${TAG_IMG} + done shell: bash if: ${{ env.EXEC_DOCKER == 'true' }} From ba43a8c7ccf90733b3974183bdaac5dcd6e5a382 Mon Sep 17 00:00:00 2001 From: Aaron Date: Tue, 17 Jan 2023 15:57:54 +0100 Subject: [PATCH 02/14] allow latest tag --- .idea/.gitignore | 8 ++++++++ .idea/colvin-deploy-action.iml | 8 ++++++++ .idea/modules.xml | 8 ++++++++ .idea/php.xml | 18 ++++++++++++++++++ .idea/vcs.xml | 6 ++++++ action.yaml | 10 ++++++++-- 6 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/colvin-deploy-action.iml create mode 100644 .idea/modules.xml create mode 100644 .idea/php.xml create mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/colvin-deploy-action.iml b/.idea/colvin-deploy-action.iml new file mode 100644 index 0000000..c956989 --- /dev/null +++ b/.idea/colvin-deploy-action.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..599c4e5 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/php.xml b/.idea/php.xml new file mode 100644 index 0000000..2c7445e --- /dev/null +++ b/.idea/php.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/action.yaml b/action.yaml index a91e5bf..385d68e 100644 --- a/action.yaml +++ b/action.yaml @@ -203,8 +203,14 @@ runs: ARRAY_CONTAINERS=(${CONTAINER_LIST}) for CONTAINER in "${ARRAY_CONTAINERS[@]}" do - docker tag ${REGISTRY}${CONTAINER}:latest ${REGISTRY}${CONTAINER}:${TAG_IMG} - docker push ${REGISTRY}${CONTAINER}:${TAG_IMG} + if [ ${WORKSPACE} == "prod" ] + then + docker push ${REGISTRY}${CONTAINER}:latest + docker push ${REGISTRY}${CONTAINER}:${TAG_IMG} + else + docker push ${REGISTRY}${CONTAINER}:${GITHUB_REF_NAME} + docker push ${REGISTRY}${CONTAINER}:${TAG_IMG} + fi done shell: bash if: ${{ env.EXEC_DOCKER == 'true' }} From 471963903361debe271f0679f3938c3b498b661c Mon Sep 17 00:00:00 2001 From: Aaron Date: Tue, 17 Jan 2023 16:14:08 +0100 Subject: [PATCH 03/14] allow latest tag --- action.yaml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/action.yaml b/action.yaml index 385d68e..39222e3 100644 --- a/action.yaml +++ b/action.yaml @@ -205,12 +205,11 @@ runs: do if [ ${WORKSPACE} == "prod" ] then - docker push ${REGISTRY}${CONTAINER}:latest - docker push ${REGISTRY}${CONTAINER}:${TAG_IMG} + docker tag ${CONTAINER} latest ${TAG_IMG} else - docker push ${REGISTRY}${CONTAINER}:${GITHUB_REF_NAME} - docker push ${REGISTRY}${CONTAINER}:${TAG_IMG} + docker tag ${CONTAINER} ${GITHUB_REF_NAME} ${TAG_IMG} fi + docker push ${REGISTRY}${CONTAINER} --all-tags done shell: bash if: ${{ env.EXEC_DOCKER == 'true' }} From a1d33dc4b2eb7b1b9aef7db099fc70ec5595a1e9 Mon Sep 17 00:00:00 2001 From: Aaron Date: Wed, 18 Jan 2023 08:48:42 +0100 Subject: [PATCH 04/14] allow latest tag --- action.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/action.yaml b/action.yaml index 39222e3..05915e6 100644 --- a/action.yaml +++ b/action.yaml @@ -205,11 +205,11 @@ runs: do if [ ${WORKSPACE} == "prod" ] then - docker tag ${CONTAINER} latest ${TAG_IMG} + docker tag ${REGISTRY}${CONTAINER}:${TAG_IMG} ${REGISTRY}${CONTAINER}:latest else - docker tag ${CONTAINER} ${GITHUB_REF_NAME} ${TAG_IMG} + docker tag ${REGISTRY}${CONTAINER}:${TAG_IMG} ${REGISTRY}${CONTAINER}:${GITHUB_REF_NAME} fi - docker push ${REGISTRY}${CONTAINER} --all-tags + docker push ${REGISTRY}${CONTAINER} --all-tags done shell: bash if: ${{ env.EXEC_DOCKER == 'true' }} From 904879ac5c3b7836e59befb7e2d0b47f352fc9c4 Mon Sep 17 00:00:00 2001 From: Aaron Date: Thu, 26 Jan 2023 12:17:00 +0100 Subject: [PATCH 05/14] allow latest and branch name tag --- action.yaml | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/action.yaml b/action.yaml index 05915e6..ac2b1d5 100644 --- a/action.yaml +++ b/action.yaml @@ -152,9 +152,23 @@ runs: - name: 'Get latest tag and auto increment version' run: | ARRAY_CONTAINERS=(${CONTAINER_LIST}) - REGEX="${TAG_PREFIX}.([0-9]+)" - LAST=`gcloud container images list-tags ${REGISTRY}${ARRAY_CONTAINERS[0]} --sort-by="TAGS" --filter="tags~^${TAG_PREFIX}" | sed '/TIMESTAMP/d' | sort -rVk2 | head -n1 | awk '{print $2}'` - if [[ ${LAST} =~ ${REGEX} ]]; then MINOR="${BASH_REMATCH[1]}"; fi + REGEX_REGISTRY="^[0-9]\.([0-9]{1,})$" + PRE_REGEX="^${TAG_PREFIX}\." + REGEX_VERSION="${PRE_REGEX}[0-9]{1,}$" + + LAST=`gcloud container images list-tags ${REGISTRY}${ARRAY_CONTAINERS[0]} --sort-by="TAGS" --filter="tags~^${REGEX_REGISTRY}" | sed '/TIMESTAMP/d' | sort -rVk2 | head -n1 | awk '{print $2}'` + IFS=',' + read -a elements <<< "$LAST" + + for (( n=0; n < ${#elements[*]}; n++)) + do + if [[ "${elements[n]}" =~ $REGEX_VERSION ]] + then + MINOR=$(echo $BASH_REMATCH | sed "s/${PRE_REGEX}//g") + break + fi + done + if [ -z ${MINOR} ]; then MINOR="0"; fi MINOR=$(echo ${MINOR} + 1 | bc) echo "TAG_IMG=${TAG_PREFIX}.${MINOR}" >> ${GITHUB_ENV} From a5fed821d1c0c1e3ff6a07377993f6f6514b4823 Mon Sep 17 00:00:00 2001 From: Aaron Date: Thu, 26 Jan 2023 12:55:15 +0100 Subject: [PATCH 06/14] allow latest and branch name tag --- action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yaml b/action.yaml index ac2b1d5..52d5d6f 100644 --- a/action.yaml +++ b/action.yaml @@ -152,7 +152,7 @@ runs: - name: 'Get latest tag and auto increment version' run: | ARRAY_CONTAINERS=(${CONTAINER_LIST}) - REGEX_REGISTRY="^[0-9]\.([0-9]{1,})$" + REGEX_REGISTRY="^[0-9]\.[0-9]{1,}$" PRE_REGEX="^${TAG_PREFIX}\." REGEX_VERSION="${PRE_REGEX}[0-9]{1,}$" From 04ce9628d563e9773364c226b5bcff46d2715acc Mon Sep 17 00:00:00 2001 From: Aaron Date: Thu, 26 Jan 2023 13:26:14 +0100 Subject: [PATCH 07/14] allow latest and branch name tag --- action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yaml b/action.yaml index 52d5d6f..f179495 100644 --- a/action.yaml +++ b/action.yaml @@ -156,7 +156,7 @@ runs: PRE_REGEX="^${TAG_PREFIX}\." REGEX_VERSION="${PRE_REGEX}[0-9]{1,}$" - LAST=`gcloud container images list-tags ${REGISTRY}${ARRAY_CONTAINERS[0]} --sort-by="TAGS" --filter="tags~^${REGEX_REGISTRY}" | sed '/TIMESTAMP/d' | sort -rVk2 | head -n1 | awk '{print $2}'` + LAST=`gcloud container images list-tags ${REGISTRY}${ARRAY_CONTAINERS[0]} --sort-by="TAGS" --filter="tags~${REGEX_REGISTRY}" | sed '/TIMESTAMP/d' | sort -rVk2 | head -n1 | awk '{print $2}'` IFS=',' read -a elements <<< "$LAST" From 0ca74259689089cda2aa18c54dce91ed524dd157 Mon Sep 17 00:00:00 2001 From: Aaron Date: Thu, 26 Jan 2023 13:50:06 +0100 Subject: [PATCH 08/14] allow latest and branch name tag --- action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yaml b/action.yaml index f179495..60d10f9 100644 --- a/action.yaml +++ b/action.yaml @@ -152,7 +152,7 @@ runs: - name: 'Get latest tag and auto increment version' run: | ARRAY_CONTAINERS=(${CONTAINER_LIST}) - REGEX_REGISTRY="^[0-9]\.[0-9]{1,}$" + REGEX_REGISTRY="^${TAG_PREFIX}\.[0-9]{1,}$" PRE_REGEX="^${TAG_PREFIX}\." REGEX_VERSION="${PRE_REGEX}[0-9]{1,}$" From 51625a63f812f9d9ef9f3ddaafda11e8d9443b99 Mon Sep 17 00:00:00 2001 From: Aaron Date: Fri, 10 Feb 2023 08:59:03 +0100 Subject: [PATCH 09/14] allow latest and branch name tag --- action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yaml b/action.yaml index 60d10f9..b10bcbc 100644 --- a/action.yaml +++ b/action.yaml @@ -156,7 +156,7 @@ runs: PRE_REGEX="^${TAG_PREFIX}\." REGEX_VERSION="${PRE_REGEX}[0-9]{1,}$" - LAST=`gcloud container images list-tags ${REGISTRY}${ARRAY_CONTAINERS[0]} --sort-by="TAGS" --filter="tags~${REGEX_REGISTRY}" | sed '/TIMESTAMP/d' | sort -rVk2 | head -n1 | awk '{print $2}'` + LAST=`gcloud container images list-tags ${REGISTRY}${ARRAY_CONTAINERS[0]} --sort-by="~TIMESTAMP" --filter="tags~${REGEX_REGISTRY}" | sed '/TIMESTAMP/d' | head -n1 | awk '{print $2}'` IFS=',' read -a elements <<< "$LAST" From 8d506b0934e6c914b71d2ed9114eaa22269b347b Mon Sep 17 00:00:00 2001 From: jlopezxs Date: Thu, 18 May 2023 12:04:19 +0200 Subject: [PATCH 10/14] sort by tag --- .idea/.gitignore | 8 -------- .idea/colvin-deploy-action.iml | 8 -------- .idea/modules.xml | 8 -------- .idea/php.xml | 18 ------------------ .idea/vcs.xml | 6 ------ action.yaml | 19 +++---------------- 6 files changed, 3 insertions(+), 64 deletions(-) delete mode 100644 .idea/.gitignore delete mode 100644 .idea/colvin-deploy-action.iml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/php.xml delete mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 13566b8..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Editor-based HTTP Client requests -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml diff --git a/.idea/colvin-deploy-action.iml b/.idea/colvin-deploy-action.iml deleted file mode 100644 index c956989..0000000 --- a/.idea/colvin-deploy-action.iml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 599c4e5..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/php.xml b/.idea/php.xml deleted file mode 100644 index 2c7445e..0000000 --- a/.idea/php.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1dd..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/action.yaml b/action.yaml index b10bcbc..3556a06 100644 --- a/action.yaml +++ b/action.yaml @@ -152,22 +152,9 @@ runs: - name: 'Get latest tag and auto increment version' run: | ARRAY_CONTAINERS=(${CONTAINER_LIST}) - REGEX_REGISTRY="^${TAG_PREFIX}\.[0-9]{1,}$" - PRE_REGEX="^${TAG_PREFIX}\." - REGEX_VERSION="${PRE_REGEX}[0-9]{1,}$" - - LAST=`gcloud container images list-tags ${REGISTRY}${ARRAY_CONTAINERS[0]} --sort-by="~TIMESTAMP" --filter="tags~${REGEX_REGISTRY}" | sed '/TIMESTAMP/d' | head -n1 | awk '{print $2}'` - IFS=',' - read -a elements <<< "$LAST" - - for (( n=0; n < ${#elements[*]}; n++)) - do - if [[ "${elements[n]}" =~ $REGEX_VERSION ]] - then - MINOR=$(echo $BASH_REMATCH | sed "s/${PRE_REGEX}//g") - break - fi - done + REGEX="${TAG_PREFIX}.([0-9]+)" + LAST=`gcloud container images list-tags ${REGISTRY}${ARRAY_CONTAINERS[0]} --sort-by="TAGS" --filter="tags~^${TAG_PREFIX}" | sed '/TIMESTAMP/d' | sort -rVk2 | head -n1 | awk '{print $2}'` + if [[ ${LAST} =~ ${REGEX} ]]; then MINOR="${BASH_REMATCH[1]}"; fi if [ -z ${MINOR} ]; then MINOR="0"; fi MINOR=$(echo ${MINOR} + 1 | bc) From 9af64f246333223909dcf71147b50af3196e7c49 Mon Sep 17 00:00:00 2001 From: mdarnaculleta <66317659+mdarnaculleta@users.noreply.github.com> Date: Thu, 14 Sep 2023 13:40:33 +0200 Subject: [PATCH 11/14] Fix to take into account more than one tag (#5) * Fix to take into account more than one tag * complete line --- action.yaml | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/action.yaml b/action.yaml index 3556a06..52fd4b0 100644 --- a/action.yaml +++ b/action.yaml @@ -153,7 +153,26 @@ runs: run: | ARRAY_CONTAINERS=(${CONTAINER_LIST}) REGEX="${TAG_PREFIX}.([0-9]+)" - LAST=`gcloud container images list-tags ${REGISTRY}${ARRAY_CONTAINERS[0]} --sort-by="TAGS" --filter="tags~^${TAG_PREFIX}" | sed '/TIMESTAMP/d' | sort -rVk2 | head -n1 | awk '{print $2}'` + #LAST=`gcloud container images list-tags ${REGISTRY}${ARRAY_CONTAINERS[0]} --sort-by="TAGS" --filter="tags~^${TAG_PREFIX}" | sed '/TIMESTAMP/d' | sort -rVk2 | head -n1 | awk '{print $2}'` + gcloud container images list-tags ${REGISTRY}${ARRAY_CONTAINERS[0]} --sort-by="TAGS" --filter="tags~^${TAG_PREFIX}" | sed '/TIMESTAMP/d' | awk '{print $2}' > output.out + cp -a output.out output2.out + + for LINE in `cat output.out` + do + COL1=`echo ${LINE} | cut -d',' -f1` + COL2=`echo ${LINE} | cut -d',' -f2` + + if [[ ${COL1} =~ ${REGEX} ]] + then + sed -i "s/^${LINE}\$/${COL1}/g" output2.out + elif [[ ${COL2} =~ ${REGEX} ]] + then + sed -i "s/^${LINE}\$/${COL2}/g" output2.out + fi + done + + LAST=`cat output2.out | sort -rV | head -n1` + if [[ ${LAST} =~ ${REGEX} ]]; then MINOR="${BASH_REMATCH[1]}"; fi if [ -z ${MINOR} ]; then MINOR="0"; fi From 01184473f96ea815d92c06ff6b8d4eac9831e7ee Mon Sep 17 00:00:00 2001 From: Manuel Viera Date: Fri, 15 Sep 2023 10:09:02 +0200 Subject: [PATCH 12/14] Refactors the way we calculate the latest tag (#7) Co-authored-by: Manuel Viera --- action.yaml | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/action.yaml b/action.yaml index 52fd4b0..a84dfdc 100644 --- a/action.yaml +++ b/action.yaml @@ -153,26 +153,7 @@ runs: run: | ARRAY_CONTAINERS=(${CONTAINER_LIST}) REGEX="${TAG_PREFIX}.([0-9]+)" - #LAST=`gcloud container images list-tags ${REGISTRY}${ARRAY_CONTAINERS[0]} --sort-by="TAGS" --filter="tags~^${TAG_PREFIX}" | sed '/TIMESTAMP/d' | sort -rVk2 | head -n1 | awk '{print $2}'` - gcloud container images list-tags ${REGISTRY}${ARRAY_CONTAINERS[0]} --sort-by="TAGS" --filter="tags~^${TAG_PREFIX}" | sed '/TIMESTAMP/d' | awk '{print $2}' > output.out - cp -a output.out output2.out - - for LINE in `cat output.out` - do - COL1=`echo ${LINE} | cut -d',' -f1` - COL2=`echo ${LINE} | cut -d',' -f2` - - if [[ ${COL1} =~ ${REGEX} ]] - then - sed -i "s/^${LINE}\$/${COL1}/g" output2.out - elif [[ ${COL2} =~ ${REGEX} ]] - then - sed -i "s/^${LINE}\$/${COL2}/g" output2.out - fi - done - - LAST=`cat output2.out | sort -rV | head -n1` - + LAST=`gcloud container images list-tags ${REGISTRY}${ARRAY_CONTAINERS[0]} --sort-by="TAGS" --filter="tags~^${TAG_PREFIX}" | sed '/TIMESTAMP/d' | awk '{print $2}' | sed -E "s/.*($REGEX).*/\1/" | sort -rVk2 | head -n1 | awk '{print $2}'` if [[ ${LAST} =~ ${REGEX} ]]; then MINOR="${BASH_REMATCH[1]}"; fi if [ -z ${MINOR} ]; then MINOR="0"; fi From bb2217f5225a1e4be47c37a568ba20a02d0c94be Mon Sep 17 00:00:00 2001 From: Manuel Viera Date: Fri, 15 Sep 2023 10:56:01 +0200 Subject: [PATCH 13/14] Refactors the way we calculate the latest tag --- action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yaml b/action.yaml index a84dfdc..8bedce5 100644 --- a/action.yaml +++ b/action.yaml @@ -153,7 +153,7 @@ runs: run: | ARRAY_CONTAINERS=(${CONTAINER_LIST}) REGEX="${TAG_PREFIX}.([0-9]+)" - LAST=`gcloud container images list-tags ${REGISTRY}${ARRAY_CONTAINERS[0]} --sort-by="TAGS" --filter="tags~^${TAG_PREFIX}" | sed '/TIMESTAMP/d' | awk '{print $2}' | sed -E "s/.*($REGEX).*/\1/" | sort -rVk2 | head -n1 | awk '{print $2}'` + LAST=`gcloud container images list-tags ${REGISTRY}${ARRAY_CONTAINERS[0]} --sort-by="TAGS" --filter="tags~^${TAG_PREFIX}" | sed '/TIMESTAMP/d' | awk '{print $2}' | sed -E "s/.*($REGEX).*/\1/" | sort -rVk2 | head -n1` if [[ ${LAST} =~ ${REGEX} ]]; then MINOR="${BASH_REMATCH[1]}"; fi if [ -z ${MINOR} ]; then MINOR="0"; fi From 3caa5154619f287755b932a57d08575f56423e21 Mon Sep 17 00:00:00 2001 From: Manuel Viera Date: Tue, 27 Feb 2024 13:05:32 +0100 Subject: [PATCH 14/14] Upgrades google-github-actions to v2 (#8) Co-authored-by: Manuel Viera --- action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yaml b/action.yaml index 8bedce5..b866281 100644 --- a/action.yaml +++ b/action.yaml @@ -107,7 +107,7 @@ runs: - name: 'GCloud get GKE credentials' id: 'get-credentials' - uses: google-github-actions/get-gke-credentials@v0 + uses: google-github-actions/get-gke-credentials@v2 with: project_id: ${{ env.PROJECT_ID }} cluster_name: ${{ env.CLUSTER }}