Static Checkout SDK version to ensure avoidance of maven repository server downtimes #10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }}" | |
curl -X POST -H 'Content-type: application/json; charset=UTF-8' \ | |
-H "Authorization: Bearer ${{ secrets.CHECKOUT_SLACK_BOT_TOKEN }}" \ | |
--data '{ | |
"channel": "C02GTS30HUN", | |
"text": "Version update found for Checkout PG Core SDK. Please find the version update details below:\nSDK Variant: React Native Standard Checkout SDK\nNew Version:${versionName}\nChangelog:${prBody}\n cc: <!subteam^S086N4NN8SU>" | |
}' \ | |
https://slack.com/api/chat.postMessage |