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_package_info.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: | echo "::set-output name=version::$(node -p "require('./package.json').version")" echo "::set-output name=buildNumber::$(node -p "require('./package.json').buildNumber")" - 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 nfa-navi.com/nfa-app -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 nfa-navi.com/nfa-app -d Production -t "${{github.event.inputs.target_versions}}" --description "${{github.event.inputs.description}}" create_release_tag: needs: generate runs-on: [default] if: success() && (github.event.inputs.environment == 'QA') # Only create tag for Prod releases, have put QA for testing 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="${{ needs.generate.outputs.package_version }}" TAG_EXISTS=$(git tag -l "$TAG_NAME") if [ "$TAG_EXISTS" ]; then echo "Tag $TAG_NAME already exists." echo "::set-output name=tag_exists::true" else echo "Tag $TAG_NAME does not exist." echo "::set-output name=tag_exists::false" fi - name: Create Git tag if: steps.check_tag.outputs.tag_exists == 'false' run: | TAG_NAME="${{ needs.generate.outputs.package_version }}" git config --local user.email "${{ github.actor }}@users.noreply.github.com" git config --local user.name "${{ github.actor }}" git tag $TAG_NAME git push origin $TAG_NAME env: GITHUB_TOKEN: ${{ secrets.MY_REPO_PAT }} - name: Create release tag run: | TAG_NAME="${{ needs.generate.outputs.package_version }}" RELEASE_NAME="Release $TAG_NAME" 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\": \"$DESCRIPTION\", \"draft\": false, \"prerelease\": false }" \ "https://api.github.com/repos/$REPO/releases" shell: bash