TP-64651: Codepush action for qa deployment (#10779)

Co-authored-by: Shivam Goyal <shivam.goyal@navi.com>
This commit is contained in:
Raaj Gopal
2024-05-09 13:53:26 +05:30
committed by GitHub
parent 60f19bd88f
commit 5e2501e01f

View File

@@ -20,97 +20,24 @@ on:
type: string type: string
default: 'bug fixes and minor ui enhancements' default: 'bug fixes and minor ui enhancements'
jobs: jobs:
generate: build:
runs-on: [default] runs-on: [ default ]
outputs: defaults:
package_version: ${{ steps.get_version.outputs.version }} run:
build_number: ${{ steps.get_version.outputs.buildNumber }} working-directory: .
steps: steps:
- name: Checkout Repository - name: Checkout Repository
uses: actions/checkout@v4 uses: actions/checkout@v4
with:
token: ${{ secrets.GH_PAT }}
- name: Setup Node.js - name: Setup Node.js
uses: actions/setup-node@v4 uses: actions/setup-node@v4
with: with:
node-version: 18.18.0 node-version: 18.18.0
- name: Get version from package.json
id: get_version
run: |
VERSION=$(node -p "require('./package.json').version")
BUILD_NUMBER=$(node -p "require('./package.json').buildNumber")
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Extracted version is $VERSION"
echo "Set version to $VERSION"
echo "buildNumber=$BUILD_NUMBER" >> $GITHUB_OUTPUT
echo "Set buildNumber to $BUILD_NUMBER"
- name: Install appcenter cli - name: Install appcenter cli
run: npm install -g appcenter-cli run: npm install -g appcenter-cli
- name: Install Node Modules - name: Install Node Modules
run: npm install run: npm install
- name: AppCenter login - name: AppCenter login
run: appcenter login --token ${{ secrets.APP_CENTER_LOGIN_TOKEN }} run: appcenter login --token ${{ secrets.APP_CENTER_LOGIN_TOKEN }}
- name: Add version name in gradle properities
run: sed -i 's/def VERSION_NAME=${{github.event.inputs.target_versions}}"/g' gradle.properties
- name: CodePush QA - name: CodePush QA
if: ((github.event.inputs.environment == 'QA' || inputs.environment == 'QA')) if: ((github.event.inputs.environment == 'QA' || inputs.environment == 'QA'))
run: appcenter codepush release-react -a rn_super_app/NaviApp -d Staging -t "${{github.event.inputs.target_versions}}" --description "${{github.event.inputs.description}}" run: appcenter codepush release-react -a navi-rn_super_app/NaviApp -d Staging -t "${{inputs.target_versions}}" --description "${{inputs.description}}"
# Below step we will enable for Production, also prod deployment needs approval so will integrate that accordingly.
create_release_tag:
needs: generate
runs-on: [default]
if: success() && (github.event.inputs.environment == 'Prod') # Only create tag for Prod releases
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_PAT }}
submodules: recursive
persist-credentials: true
- name: Check if tag exists
id: check_tag
run: |
TAG_NAME="${{ needs.generate.outputs.package_version }}"
EXISTING_TAG=$(git ls-remote --tags origin refs/tags/$TAG_NAME)
if [[ -z "$EXISTING_TAG" ]]; then
echo "Tag $TAG_NAME does not exist."
echo "tag_exists=false" >> $GITHUB_ENV
else
echo "Tag $TAG_NAME already exists."
echo "tag_exists=true" >> $GITHUB_ENV
fi
- name: Create and push tag
if: env.tag_exists == 'false'
run: |
TAG_NAME="${{ needs.generate.outputs.package_version }}"
# git config --local user.email "${{ github.actor }}@github.com"
git config --local user.name "${{ github.actor }}"
git tag $TAG_NAME
git push origin $TAG_NAME
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
- name: Create release tag
run: |
TAG_NAME="${{ needs.generate.outputs.package_version }}"
BUILD_NUMBER="${{ needs.generate.outputs.build_number }}"
RELEASE_NAME="$TAG_NAME (build $BUILD_NUMBER) code push"
DESCRIPTION="${{ github.event.inputs.description }}"
REPO="navi-medici/address-verification-app"
BRANCH_NAME="${GITHUB_REF#refs/heads/}"
curl -X POST \
-H "Authorization: token ${{ secrets.GH_PAT }}" \
-H "Content-Type: application/json" \
-d "{
\"tag_name\": \"$TAG_NAME\",
\"target_commitish\": \"$BRANCH_NAME\",
\"name\": \"$RELEASE_NAME\",
\"body\": \"\",
\"draft\": false,
\"prerelease\": false,
\"generate_release_notes\": true
}" \
"https://api.github.com/repos/$REPO/releases"
shell: bash