Skip to content

Static Checkout SDK version to ensure avoidance of maven repository server downtimes #13

Static Checkout SDK version to ensure avoidance of maven repository server downtimes

Static Checkout SDK version to ensure avoidance of maven repository server downtimes #13

name: Version trigger workflow
on:
pull_request:
jobs:
build:
runs-on: macos-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Fetch the pull request diff
run: git fetch origin ${{ github.event.pull_request.base.sha }} ${{ github.sha }}
- name: Check if a particular file has changed
id: check_file
run: |
# Check if 'package.json' has changed in the PR
if git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep -q 'package.json'; then
echo "file_changed=true" >> $GITHUB_ENV
else
echo "file_changed=false" >> $GITHUB_ENV
fi
- name: Post message to Slack
if: env.file_changed == 'true'
run: |
#get version_line from package.json
version_line=$(grep -m 1 "\"version\":" ${GITHUB_WORKSPACE}/package.json)
#versionName substring generation
pattern1="\"version\": \""
pattern2="\","
versionName=${version_line/$pattern1/}
versionName=${versionName/$pattern2/}
prBody="${{ github.event.pull_request.body }}"
finalVersionName="${versionName}"
echo "$prBody"
echo "$versionName"
curl -X POST -H 'Content-type: application/json; charset=UTF-8' \
-H "Authorization: Bearer ${{ secrets.CHECKOUT_SLACK_BOT_TOKEN }}" \
--data '{\"channel\":\"C1GMWKRF1\",\"text\":\"Hey, <!subteam^S6R84Q3J6>Found one version update for one of Checkout PG Core SDKs. Please find the version update details below:\\nSDK Variant: React Native Standard Checkout SDK\\nNew Version:${versionName}\\nChangelog:${prBody}\\ncc:<!subteam^S086N4NN8SU>\"}' \
https://slack.com/api/chat.postMessage