From 210ec935fb03d55e1dad232faf58118ebd96e0b1 Mon Sep 17 00:00:00 2001 From: Shivam Goyal Date: Mon, 27 Mar 2023 13:23:22 +0530 Subject: [PATCH] TP-17680 | Auto Branch Cut GitHub Action (#5825) * TP-17680 | Auto Branch Cut GitHub Action * TP-17680 | Rename Jira Ticket to Jira Issue * TP-17680 | Moving to generic Branch Cut approach * TP-17680 | Fix Syntax and Add better step-names --- .github/workflows/branch_cut.yml | 43 ++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/branch_cut.yml diff --git a/.github/workflows/branch_cut.yml b/.github/workflows/branch_cut.yml new file mode 100644 index 0000000000..bdf4c86dd6 --- /dev/null +++ b/.github/workflows/branch_cut.yml @@ -0,0 +1,43 @@ +name: Branch Cut CI + +on: + workflow_dispatch: + inputs: + version_code: + description: App Version Code (e.g., 301) + required: true + type: string + version_name: + description: App Version Name (e.g., 3.0.1) + required: true + type: string + jira_issue: + description: Jira Issue ID (e.g., TP-12345) + required: true + type: string + branch_prefix: + description: Branch Prefix (e.g., release-) + required: true + default: 'release-' + type: string + +jobs: + branch-cut: + runs-on: [ default ] + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Git Credentials for @${{ github.actor }} + run: | + git config --global user.email "${GITHUB_ACTOR//-/.}@navi.com" + git config --global user.name "$GITHUB_ACTOR" + - name: Checkout ${{ github.event.inputs.branch_prefix }}${{ github.event.inputs.version_name }} from ${{ github.ref_name }} + run: git checkout -b ${{ github.event.inputs.branch_prefix }}${{ github.event.inputs.version_name }} + - name: Update Version Name (${{ github.event.inputs.version_name }}) & Version Code (${{ github.event.inputs.version_code }}) + run: | + sed -i 's/def VERSION_NAME = "[0-9].*"/def VERSION_NAME = "${{ github.event.inputs.version_name }}"/g' app/build.gradle + sed -i 's/def VERSION_CODE = [0-9].*/def VERSION_CODE = ${{ github.event.inputs.version_code }}/g' app/build.gradle + - name: Commit Version Changes + run: git commit app/build.gradle -m "${{ github.event.inputs.jira_issue }} | Bump Project Version to ${{ github.event.inputs.version_name }} (${{ github.event.inputs.version_code }})" + - name: Push ${{ github.event.inputs.branch_prefix }}${{ github.event.inputs.version_name }} Branch + run: git push -u origin ${{ github.event.inputs.branch_prefix }}${{ github.event.inputs.version_name }}