Merge branch 'main' of https://github.com/PWI-Works/pwi-auth-flutter #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: Update Patch Version | |
on: | |
push: | |
branches: [ main ] | |
jobs: | |
increment-version: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Increment patch version | |
run: | | |
old_version=$(grep '^version:' pubspec.yaml | sed 's/version: //') | |
IFS='.' read -r major minor patch <<< "$old_version" | |
new_patch=$((patch+1)) | |
new_version="$major.$minor.$new_patch" | |
sed -i "s/version: .*/version: $new_version/g" pubspec.yaml | |
- name: Commit changes | |
run: | | |
git config user.name github-actions | |
git config user.email github-actions@github.com | |
git add pubspec.yaml | |
git commit -m "Increment patch version" | |
git push | |
- name: Notify External Webhook | |
env: | |
WEBHOOK_URL: "https://hook.us1.make.com/pj68jejm7paquq49r3yvde9ccjb5b5hp" | |
MESSAGE: "${{ github.event.head_commit.message }}" | |
AUTHOR: "${{ github.actor }}" | |
run: | | |
# Construct JSON payload using jq to safely escape variables | |
PAYLOAD=$(jq -n \ | |
--arg text "pwi-auth-flutter package updated. Please run flutter pub upgrade pwi_auth to realize changes." \ | |
--arg message "$MESSAGE" \ | |
--arg author "$AUTHOR" \ | |
--arg project "pwi-auth-flutter" \ | |
--arg channel "live" \ | |
'{ | |
text: $text, | |
message: $message, | |
author: $author, | |
project: $project, | |
channel: $channel | |
}') | |
# Send POST request with the constructed payload | |
curl -X POST "$WEBHOOK_URL" \ | |
-H "Content-Type: application/json" \ | |
-d "$PAYLOAD" |