From 6268021954f896b62918c42037f880f2392cbd45 Mon Sep 17 00:00:00 2001 From: Shakar Bakr <5h4k4r.b4kr@gmail.com> Date: Wed, 13 Dec 2023 11:40:20 +0300 Subject: [PATCH 01/16] Add metadata to image.yaml Aggregate production releases Signed-off-by: Shakar Bakr <5h4k4r.b4kr@gmail.com> --- action.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index cfe4ba3..39e4536 100644 --- a/action.yml +++ b/action.yml @@ -147,6 +147,7 @@ runs: echo "#########################################################################################" > $TARGET_FILE echo "# This file was automatically generated by the auto-deploy action. Do not edit manually.#" >> $TARGET_FILE echo -e "#########################################################################################\n" >> $TARGET_FILE + echo -e "# GITHUB_REPOSITORY: ${{ github.repository }}" >> $TARGET_FILE export IMAGE_TAG="${FULL_IMAGE_TAG##*:}" # Removes everything up to and including the last colon export GITHUB_REPO_URL="${{ github.server_url }}/${{ github.repository }}" @@ -196,7 +197,9 @@ runs: if [[ $(gh pr list --state open --base main --head $HEAD_BRANCH) ]]; then echo "PR already exists" else - if [ $TARGET_ENV == "production" ] || [ $TARGET_ENV == "staging" ]; then + if [ $TARGET_ENV == "production" ]; then + export pr_url=$(gh pr create --title "Production release" --body "This PR was automatically created by the auto-deploy action" --base main --head $HEAD_BRANCH) + elif [ $TARGET_ENV == "staging" ]; then export pr_url=$(gh pr create --title "chore: Update ${{ inputs.component-name }} image tag in ${{ steps.get-environment.outputs.environment }}" --body "This PR was automatically created by the auto-deploy action" --base main --head $HEAD_BRANCH) else export pr_url=$(gh pr create --title "chore: Update ${{ inputs.component-name }} image tag in ${{ steps.get-environment.outputs.environment }}" --body "This PR was automatically created by the auto-deploy action" --base main --head $HEAD_BRANCH --label $LABEL_NAME) From 13c3a595dcdbaaa24c26a9b2bca9fcc6b8444a03 Mon Sep 17 00:00:00 2001 From: Shakar Bakr <5h4k4r.b4kr@gmail.com> Date: Wed, 13 Dec 2023 13:34:08 +0300 Subject: [PATCH 02/16] Fix target branch name for production releases Signed-off-by: Shakar Bakr <5h4k4r.b4kr@gmail.com> --- action.yml | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index 39e4536..710852b 100644 --- a/action.yml +++ b/action.yml @@ -105,11 +105,26 @@ runs: run: gh label create "$LABEL_NAME" --force --color "$LABEL_COLOR" --description "$LABEL_DESCRIPTION" + - name: Get branch name + id: get-branch-name + shell: bash + env: + TARGET_ENV: ${{ steps.get-environment.outputs.environment }} + run: | + + if [ $TARGET_ENV == "production" ]; then + BRANCH_NAME="prod-release" + else + BRANCH_NAME=update-${{ steps.get-environment.outputs.environment }}-${{ inputs.component-name }} + fi + + echo "TARGET_BRANCH=$BRANCH_NAME" >> $GITHUB_OUTPUT + - name: Create branch if not exists shell: bash env: TARGET_FILE: ${{ inputs.component-name }}/${{ steps.find-target-file.outputs.target_file }} - TARGET_BRANCH: update-${{ steps.get-environment.outputs.environment }}-${{ inputs.component-name }} + TARGET_BRANCH: ${{ steps.get-branch-name.outputs.BRANCH_NAME }} run: | # Do not create a new branch if the branch already exists @@ -138,7 +153,7 @@ runs: GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }} FULL_IMAGE_TAG: ${{ inputs.image-tag }} TARGET_FILE: ${{ inputs.component-name }}/${{ steps.find-target-file.outputs.target_file }} - TARGET_BRANCH: update-${{ steps.get-environment.outputs.environment }}-${{ inputs.component-name }} + TARGET_BRANCH: ${{ steps.get-branch-name.outputs.BRANCH_NAME }} run: | @@ -185,7 +200,7 @@ runs: LABEL_NAME: auto-deploy TARGET_ENV: ${{ steps.get-environment.outputs.environment }} TARGET_FILE: ${{ steps.find-target-file.outputs.target_file }} - HEAD_BRANCH: update-${{ steps.get-environment.outputs.environment }}-${{ inputs.component-name }} + HEAD_BRANCH: ${{ steps.get-branch-name.outputs.BRANCH_NAME }} IS_COMMIT: ${{ steps.commit.outputs.commit }} run: | # reset the local changes and pull changes from the remote branch (Because we are using the REST API to commit changes and not the git cli) From fd87dd5c9868dd69f1729829ec224c51d7073ad1 Mon Sep 17 00:00:00 2001 From: Shakar Bakr <5h4k4r.b4kr@gmail.com> Date: Wed, 13 Dec 2023 13:38:11 +0300 Subject: [PATCH 03/16] Fix target branch name Signed-off-by: Shakar Bakr <5h4k4r.b4kr@gmail.com> --- action.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index 710852b..1f140a5 100644 --- a/action.yml +++ b/action.yml @@ -124,7 +124,7 @@ runs: shell: bash env: TARGET_FILE: ${{ inputs.component-name }}/${{ steps.find-target-file.outputs.target_file }} - TARGET_BRANCH: ${{ steps.get-branch-name.outputs.BRANCH_NAME }} + TARGET_BRANCH: ${{ steps.get-branch-name.outputs.TARGET_BRANCH }} run: | # Do not create a new branch if the branch already exists @@ -153,7 +153,7 @@ runs: GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }} FULL_IMAGE_TAG: ${{ inputs.image-tag }} TARGET_FILE: ${{ inputs.component-name }}/${{ steps.find-target-file.outputs.target_file }} - TARGET_BRANCH: ${{ steps.get-branch-name.outputs.BRANCH_NAME }} + TARGET_BRANCH: ${{ steps.get-branch-name.outputs.TARGET_BRANCH }} run: | @@ -200,7 +200,7 @@ runs: LABEL_NAME: auto-deploy TARGET_ENV: ${{ steps.get-environment.outputs.environment }} TARGET_FILE: ${{ steps.find-target-file.outputs.target_file }} - HEAD_BRANCH: ${{ steps.get-branch-name.outputs.BRANCH_NAME }} + HEAD_BRANCH: ${{ steps.get-branch-name.outputs.TARGET_BRANCH }} IS_COMMIT: ${{ steps.commit.outputs.commit }} run: | # reset the local changes and pull changes from the remote branch (Because we are using the REST API to commit changes and not the git cli) From c79063045cb536825a1c86de5ab394533e75fbba Mon Sep 17 00:00:00 2001 From: Shakar Bakr <5h4k4r.b4kr@gmail.com> Date: Wed, 13 Dec 2023 13:40:37 +0300 Subject: [PATCH 04/16] tempo: change target_env to production Signed-off-by: Shakar Bakr <5h4k4r.b4kr@gmail.com> --- action.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 1f140a5..4274102 100644 --- a/action.yml +++ b/action.yml @@ -109,7 +109,8 @@ runs: id: get-branch-name shell: bash env: - TARGET_ENV: ${{ steps.get-environment.outputs.environment }} + # TODO: revert this to ${{ steps.get-environment.outputs.environment }} when we are done testing + TARGET_ENV: production run: | if [ $TARGET_ENV == "production" ]; then From 5e13b4af43fc17784e2f3fa26d9cd568278f0def Mon Sep 17 00:00:00 2001 From: Shakar Bakr <5h4k4r.b4kr@gmail.com> Date: Wed, 13 Dec 2023 13:42:35 +0300 Subject: [PATCH 05/16] Revert "tempo: change target_env to production" This reverts commit c79063045cb536825a1c86de5ab394533e75fbba. --- action.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 4274102..1f140a5 100644 --- a/action.yml +++ b/action.yml @@ -109,8 +109,7 @@ runs: id: get-branch-name shell: bash env: - # TODO: revert this to ${{ steps.get-environment.outputs.environment }} when we are done testing - TARGET_ENV: production + TARGET_ENV: ${{ steps.get-environment.outputs.environment }} run: | if [ $TARGET_ENV == "production" ]; then From c9088a7b909de197fd8bffb8cfd6ac5573856960 Mon Sep 17 00:00:00 2001 From: Shakar Bakr <5h4k4r.b4kr@gmail.com> Date: Wed, 13 Dec 2023 13:42:50 +0300 Subject: [PATCH 06/16] tempo: change target_env to production Signed-off-by: Shakar Bakr <5h4k4r.b4kr@gmail.com> --- action.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 1f140a5..f0830b8 100644 --- a/action.yml +++ b/action.yml @@ -70,7 +70,8 @@ runs: else environment=dev fi - echo "environment=$environment" >> $GITHUB_OUTPUT + # TODO: revert this to echo "environment=$environment" >> $GITHUB_OUTPUT when done with testing + echo "environment=production" >> $GITHUB_OUTPUT - name: Find target file id: find-target-file From adb12a732a50d49ea2c71fa351b3848878288b9f Mon Sep 17 00:00:00 2001 From: Shakar Bakr <5h4k4r.b4kr@gmail.com> Date: Wed, 13 Dec 2023 13:50:49 +0300 Subject: [PATCH 07/16] Add new line Signed-off-by: Shakar Bakr <5h4k4r.b4kr@gmail.com> --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index f0830b8..cb10ca8 100644 --- a/action.yml +++ b/action.yml @@ -163,7 +163,7 @@ runs: echo "#########################################################################################" > $TARGET_FILE echo "# This file was automatically generated by the auto-deploy action. Do not edit manually.#" >> $TARGET_FILE echo -e "#########################################################################################\n" >> $TARGET_FILE - echo -e "# GITHUB_REPOSITORY: ${{ github.repository }}" >> $TARGET_FILE + echo -e "# GITHUB_REPOSITORY: ${{ github.repository }}\n" >> $TARGET_FILE export IMAGE_TAG="${FULL_IMAGE_TAG##*:}" # Removes everything up to and including the last colon export GITHUB_REPO_URL="${{ github.server_url }}/${{ github.repository }}" From b10d5b93e44a482962676e09bf7c1f7870c8ea60 Mon Sep 17 00:00:00 2001 From: Shakar Bakr <5h4k4r.b4kr@gmail.com> Date: Wed, 13 Dec 2023 13:54:07 +0300 Subject: [PATCH 08/16] Fixes new line Signed-off-by: Shakar Bakr <5h4k4r.b4kr@gmail.com> --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index cb10ca8..694800a 100644 --- a/action.yml +++ b/action.yml @@ -163,7 +163,7 @@ runs: echo "#########################################################################################" > $TARGET_FILE echo "# This file was automatically generated by the auto-deploy action. Do not edit manually.#" >> $TARGET_FILE echo -e "#########################################################################################\n" >> $TARGET_FILE - echo -e "# GITHUB_REPOSITORY: ${{ github.repository }}\n" >> $TARGET_FILE + echo -e "# GITHUB_REPOSITORY: ${{ github.repository }} \n" >> $TARGET_FILE export IMAGE_TAG="${FULL_IMAGE_TAG##*:}" # Removes everything up to and including the last colon export GITHUB_REPO_URL="${{ github.server_url }}/${{ github.repository }}" From 164b6aaeb965afcf6536471e201d0f099d707865 Mon Sep 17 00:00:00 2001 From: Shakar Bakr <5h4k4r.b4kr@gmail.com> Date: Wed, 13 Dec 2023 13:55:35 +0300 Subject: [PATCH 09/16] Update new line additions Signed-off-by: Shakar Bakr <5h4k4r.b4kr@gmail.com> --- action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 694800a..30be043 100644 --- a/action.yml +++ b/action.yml @@ -162,8 +162,8 @@ runs: echo "#########################################################################################" > $TARGET_FILE echo "# This file was automatically generated by the auto-deploy action. Do not edit manually.#" >> $TARGET_FILE - echo -e "#########################################################################################\n" >> $TARGET_FILE - echo -e "# GITHUB_REPOSITORY: ${{ github.repository }} \n" >> $TARGET_FILE + echo -e "#########################################################################################" >> $TARGET_FILE + echo -e "# GITHUB_REPOSITORY: ${{ github.repository }} \n\n" >> $TARGET_FILE export IMAGE_TAG="${FULL_IMAGE_TAG##*:}" # Removes everything up to and including the last colon export GITHUB_REPO_URL="${{ github.server_url }}/${{ github.repository }}" From c3ee7174ee1031195b41cf47c73436f3ac2be3ed Mon Sep 17 00:00:00 2001 From: Shakar Bakr <5h4k4r.b4kr@gmail.com> Date: Wed, 13 Dec 2023 13:56:38 +0300 Subject: [PATCH 10/16] Update new line additions Signed-off-by: Shakar Bakr <5h4k4r.b4kr@gmail.com> --- action.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 30be043..b2a981f 100644 --- a/action.yml +++ b/action.yml @@ -163,7 +163,8 @@ runs: echo "#########################################################################################" > $TARGET_FILE echo "# This file was automatically generated by the auto-deploy action. Do not edit manually.#" >> $TARGET_FILE echo -e "#########################################################################################" >> $TARGET_FILE - echo -e "# GITHUB_REPOSITORY: ${{ github.repository }} \n\n" >> $TARGET_FILE + echo -e "# GITHUB_REPOSITORY: ${{ github.repository }}" >> $TARGET_FILE + echo -e "\n" >> $TARGET_FILE export IMAGE_TAG="${FULL_IMAGE_TAG##*:}" # Removes everything up to and including the last colon export GITHUB_REPO_URL="${{ github.server_url }}/${{ github.repository }}" From 1f99ada312b8ad689479811643b6f003ab57780f Mon Sep 17 00:00:00 2001 From: Shakar Bakr <5h4k4r.b4kr@gmail.com> Date: Wed, 13 Dec 2023 13:58:31 +0300 Subject: [PATCH 11/16] Update new line additions Signed-off-by: Shakar Bakr <5h4k4r.b4kr@gmail.com> --- action.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/action.yml b/action.yml index b2a981f..34ac5df 100644 --- a/action.yml +++ b/action.yml @@ -163,8 +163,7 @@ runs: echo "#########################################################################################" > $TARGET_FILE echo "# This file was automatically generated by the auto-deploy action. Do not edit manually.#" >> $TARGET_FILE echo -e "#########################################################################################" >> $TARGET_FILE - echo -e "# GITHUB_REPOSITORY: ${{ github.repository }}" >> $TARGET_FILE - echo -e "\n" >> $TARGET_FILE + printf "# GITHUB_REPOSITORY: ${{ github.repository }}\n" >> $TARGET_FILE export IMAGE_TAG="${FULL_IMAGE_TAG##*:}" # Removes everything up to and including the last colon export GITHUB_REPO_URL="${{ github.server_url }}/${{ github.repository }}" From 8f9867110afda0b6a40f89c5942a29eabdb13242 Mon Sep 17 00:00:00 2001 From: Shakar Bakr <5h4k4r.b4kr@gmail.com> Date: Wed, 13 Dec 2023 14:03:17 +0300 Subject: [PATCH 12/16] Update github env Signed-off-by: Shakar Bakr <5h4k4r.b4kr@gmail.com> --- action.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 34ac5df..bff1162 100644 --- a/action.yml +++ b/action.yml @@ -155,6 +155,8 @@ runs: FULL_IMAGE_TAG: ${{ inputs.image-tag }} TARGET_FILE: ${{ inputs.component-name }}/${{ steps.find-target-file.outputs.target_file }} TARGET_BRANCH: ${{ steps.get-branch-name.outputs.TARGET_BRANCH }} + GITHUB_REPOSITORY: ${{ github.repository }} + GITHUB_SERVER_URL: ${{ github.server_url }} run: | @@ -163,10 +165,10 @@ runs: echo "#########################################################################################" > $TARGET_FILE echo "# This file was automatically generated by the auto-deploy action. Do not edit manually.#" >> $TARGET_FILE echo -e "#########################################################################################" >> $TARGET_FILE - printf "# GITHUB_REPOSITORY: ${{ github.repository }}\n" >> $TARGET_FILE + printf "# GITHUB_REPOSITORY: $GITHUB_REPOSITORY\n" >> $TARGET_FILE export IMAGE_TAG="${FULL_IMAGE_TAG##*:}" # Removes everything up to and including the last colon - export GITHUB_REPO_URL="${{ github.server_url }}/${{ github.repository }}" + export GITHUB_REPO_URL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" # Initialize the YAML output yq -i ' From dfdf40e177200f7d7100daec7216ea2356d63412 Mon Sep 17 00:00:00 2001 From: Shakar Bakr <5h4k4r.b4kr@gmail.com> Date: Wed, 13 Dec 2023 14:07:50 +0300 Subject: [PATCH 13/16] Change it to echo Signed-off-by: Shakar Bakr <5h4k4r.b4kr@gmail.com> --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index bff1162..35cae8f 100644 --- a/action.yml +++ b/action.yml @@ -165,7 +165,7 @@ runs: echo "#########################################################################################" > $TARGET_FILE echo "# This file was automatically generated by the auto-deploy action. Do not edit manually.#" >> $TARGET_FILE echo -e "#########################################################################################" >> $TARGET_FILE - printf "# GITHUB_REPOSITORY: $GITHUB_REPOSITORY\n" >> $TARGET_FILE + echo -e "# GITHUB_REPOSITORY: $GITHUB_REPOSITORY\n" >> $TARGET_FILE export IMAGE_TAG="${FULL_IMAGE_TAG##*:}" # Removes everything up to and including the last colon export GITHUB_REPO_URL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" From c5681398644e8490a53dfd3e082aca9d1f169a05 Mon Sep 17 00:00:00 2001 From: Shakar Bakr <5h4k4r.b4kr@gmail.com> Date: Wed, 13 Dec 2023 14:09:16 +0300 Subject: [PATCH 14/16] Add new line Signed-off-by: Shakar Bakr <5h4k4r.b4kr@gmail.com> --- action.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 35cae8f..4254f4d 100644 --- a/action.yml +++ b/action.yml @@ -165,7 +165,8 @@ runs: echo "#########################################################################################" > $TARGET_FILE echo "# This file was automatically generated by the auto-deploy action. Do not edit manually.#" >> $TARGET_FILE echo -e "#########################################################################################" >> $TARGET_FILE - echo -e "# GITHUB_REPOSITORY: $GITHUB_REPOSITORY\n" >> $TARGET_FILE + echo -e "# GITHUB_REPOSITORY: $GITHUB_REPOSITORY" >> $TARGET_FILE + echo -e "\n" >> $TARGET_FILE export IMAGE_TAG="${FULL_IMAGE_TAG##*:}" # Removes everything up to and including the last colon export GITHUB_REPO_URL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" From 71bd4adcff7d86165724b329d21ee269eeaaf704 Mon Sep 17 00:00:00 2001 From: Shakar Bakr <5h4k4r.b4kr@gmail.com> Date: Thu, 14 Dec 2023 14:16:42 +0300 Subject: [PATCH 15/16] Revert "tempo: change target_env to production" This reverts commit c9088a7b909de197fd8bffb8cfd6ac5573856960. --- action.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 4254f4d..d850713 100644 --- a/action.yml +++ b/action.yml @@ -70,8 +70,7 @@ runs: else environment=dev fi - # TODO: revert this to echo "environment=$environment" >> $GITHUB_OUTPUT when done with testing - echo "environment=production" >> $GITHUB_OUTPUT + echo "environment=$environment" >> $GITHUB_OUTPUT - name: Find target file id: find-target-file From 538c29c41b10012aa934c71aaa3b757b4cd9fcd6 Mon Sep 17 00:00:00 2001 From: "Shkar T. Noori" Date: Sun, 17 Dec 2023 14:32:31 +0300 Subject: [PATCH 16/16] Small improvements --- action.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/action.yml b/action.yml index d850713..a934f7c 100644 --- a/action.yml +++ b/action.yml @@ -163,9 +163,8 @@ runs: echo "#########################################################################################" > $TARGET_FILE echo "# This file was automatically generated by the auto-deploy action. Do not edit manually.#" >> $TARGET_FILE - echo -e "#########################################################################################" >> $TARGET_FILE - echo -e "# GITHUB_REPOSITORY: $GITHUB_REPOSITORY" >> $TARGET_FILE - echo -e "\n" >> $TARGET_FILE + echo "#########################################################################################" >> $TARGET_FILE + echo "# GITHUB_REPOSITORY: $GITHUB_REPOSITORY" >> $TARGET_FILE export IMAGE_TAG="${FULL_IMAGE_TAG##*:}" # Removes everything up to and including the last colon export GITHUB_REPO_URL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" @@ -216,7 +215,7 @@ runs: echo "PR already exists" else if [ $TARGET_ENV == "production" ]; then - export pr_url=$(gh pr create --title "Production release" --body "This PR was automatically created by the auto-deploy action" --base main --head $HEAD_BRANCH) + export pr_url=$(gh pr create --title "Production release" --body "Populating PR description with release notes :clock130: ..." --base main --head $HEAD_BRANCH) elif [ $TARGET_ENV == "staging" ]; then export pr_url=$(gh pr create --title "chore: Update ${{ inputs.component-name }} image tag in ${{ steps.get-environment.outputs.environment }}" --body "This PR was automatically created by the auto-deploy action" --base main --head $HEAD_BRANCH) else