From dfe2d57c06372fd220d27ffa92a9f1237464ee83 Mon Sep 17 00:00:00 2001 From: Naresh Kumar D Date: Thu, 11 Jun 2026 11:04:28 +0530 Subject: [PATCH 1/2] Create tag.yml --- .github/workflows/tag.yml | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/tag.yml diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml new file mode 100644 index 0000000..a1197f1 --- /dev/null +++ b/.github/workflows/tag.yml @@ -0,0 +1,39 @@ +# Whenever there is a pull request merged into the branches, create tag +name: Update Environment Tag +on: + pull_request: + types: [closed] + branches: + - develop + - staging + - production +jobs: + update-tag: + if: github.event.pull_request.merged == true + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 1 + - name: Get the current branch name + id: get_branch + run: | + TARGET_BRANCH="${{ github.event.pull_request.base.ref }}" + + if [ "$TARGET_BRANCH" = "develop" ]; then + echo "ENV_TAG=dev" >> $GITHUB_ENV + elif [ "$TARGET_BRANCH" = "staging" ]; then + echo "ENV_TAG=stage" >> $GITHUB_ENV + elif [ "$TARGET_BRANCH" = "production" ]; then + echo "ENV_TAG=prod" >> $GITHUB_ENV + fi + - name: Force update tag + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + echo "Targeting tag: ${{ env.ENV_TAG }}" + git tag -f $ENV_TAG + git push origin $ENV_TAG --force \ No newline at end of file From 9165bfa7da1472a8ab44885da4f4e9cb7ed575b9 Mon Sep 17 00:00:00 2001 From: Naresh Kumar D Date: Thu, 11 Jun 2026 11:12:34 +0530 Subject: [PATCH 2/2] Update tag.yml --- .github/workflows/tag.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml index a1197f1..f42750b 100644 --- a/.github/workflows/tag.yml +++ b/.github/workflows/tag.yml @@ -29,8 +29,11 @@ jobs: echo "ENV_TAG=stage" >> $GITHUB_ENV elif [ "$TARGET_BRANCH" = "production" ]; then echo "ENV_TAG=prod" >> $GITHUB_ENV + else + echo "ENV_TAG=" >> $GITHUB_ENV fi - name: Force update tag + if: ${{ env.ENV_TAG != '' }} run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com"