NTP-12345| Create codepushTele.yml

This commit is contained in:
Aman Singh
2024-11-12 15:06:06 +05:30
committed by GitHub
parent aefaa37f81
commit 9d91ecabc0

155
.github/workflows/codepushTele.yml vendored Normal file
View File

@@ -0,0 +1,155 @@
name: code-push-cli
on:
workflow_dispatch:
inputs:
environment:
description: Choose build environment
required: true
type: choice
options:
- QA
- Prod
target_versions:
description: please enter target versions
required: true
type: string
default: '2.3.4'
description:
description: Enter please add change log
required: true
type: string
default: 'login sso'
jobs:
generate:
runs-on: [default]
outputs:
package_version: ${{ steps.get_version.outputs.version }}
build_number: ${{ steps.get_version.outputs.buildNumber }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
token: ${{ secrets.MY_REPO_PAT }}
submodules: recursive
- name: Set Node.js 16.x
uses: actions/setup-node@v3
with:
node-version: 16.x
- 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 yarn
run: npm install --global yarn
- name: Install appcenter cli
run: npm install -g appcenter-cli
- name: Install dependency
run: yarn
- name: AppCenter login
run: appcenter login --token ${{ secrets.APP_CENTER_LOGIN_TOKEN }}
- name: CodePush QA
if: ((github.event.inputs.environment == 'QA' || inputs.environment == 'QA'))
run: yarn move:qa && appcenter codepush release-react -a varnit.goyal-navi.com/cosmos-tele-app-prod -d Staging -t "${{github.event.inputs.target_versions}}" --description "${{github.event.inputs.description}}"
- name: CodePush Prod
if: ((github.event.inputs.environment == 'Prod' || inputs.environment == 'Prod'))
run: yarn move:prod && appcenter codepush release-react -a varnit.goyal-navi.com/cosmos-tele-app-prod -d Production -t "${{github.event.inputs.target_versions}}" --description "${{github.event.inputs.description}}"
generate_source_map:
needs: generate
runs-on: [default]
if: success() && (github.event.inputs.environment == 'Prod') # Only create source map for Prod releases
steps:
- name: Checkout
uses: actions/checkout@v2
with:
token: ${{ secrets.MY_REPO_PAT }}
submodules: recursive
- name: Set Node.js 16.x
uses: actions/setup-node@v3
with:
node-version: 16.x
- name: Install yarn
run: npm install --global yarn
- name: Install dependency
run: yarn
- name: Generate Android Bundle and Source Map
run: |
npx react-native bundle \
--dev false \
--minify true \
--platform android \
--entry-file index.js \
--reset-cache \
--bundle-output index.android.bundle \
--sourcemap-output index.android.bundle.map
- name: Upload Source Map
uses: actions/upload-artifact@v3
with:
name: source-map
path: index.android.bundle.map
create_release_tag:
needs: generate_source_map
runs-on: [default]
if: success() && (github.event.inputs.environment == 'Prod') # Only create tag for Prod releases
steps:
- name: Checkout
uses: actions/checkout@v2
with:
token: ${{ secrets.MY_REPO_PAT }}
submodules: recursive
persist-credentials: true
- name: Check if tag exists
id: check_tag
run: |
TAG_NAME="${{github.event.inputs.version_name || inputs.version_name}}"
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="${{github.event.inputs.version_name || inputs.version_name}}"
# 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 --no-verify
env:
GITHUB_TOKEN: ${{ secrets.MY_REPO_PAT }}
- name: Create release tag
run: |
TAG_NAME="${{github.event.inputs.version_name || inputs.version_name}}"
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.MY_REPO_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