Feat/maven version change #14
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: Gather necessary data for the Slack notification | |
id: data_for_notif | |
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 "new_version=$finalVersionName" >> GITHUB_ENV | |
echo "pr_changelog=$prBody" >> GITHUB_ENV | |
- name: Post message to Slack | |
if: env.file_changed == 'true' | |
run: | | |
curl -X POST -H 'Content-type: application/json; charset=UTF-8' \ | |
-H "Authorization: Bearer ${{ secrets.CHECKOUT_SLACK_BOT_TOKEN }}" \ | |
--data '{ | |
"channel": "C02GTS30HUN", | |
"text": "Hey, looks like one of the Checkout PG Core SDKs is being released.\nVariant: React Native Standard Checkout SDK\nVersion: `${{ env.new_version }}`\nChangelog:\n`${{ env.pr_changelog }}`\n cc: <!subteam^S086N4NN8SU>" | |
}' \ | |
https://slack.com/api/chat.postMessage |