ci: sync release to pg branch (#35888)
## Description This CI job is responsible for syncing changes from the release branch to the pg branch. This happens for every commit merged to release branch, similar to `Sync Community Workflow` Fixes #`Issue Number` ## Automation /ok-to-test tags="@tag.Sanity" ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/10571814611> > Commit: 9bc44fc0cc762d52854da3b4e2f8c3e995909ccd > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=10571814611&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.Sanity` > Spec: > <hr>Tue, 27 Aug 2024 05:00:52 UTC <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced an automated workflow for merging changes from the release branch to the pg branch, enhancing integration and development efficiency. - Added notifications for merge conflicts to improve communication and resolution tracking. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
parent
0a3492ff96
commit
c79b62e536
84
.github/workflows/sync-release-to-pg.yml
vendored
Normal file
84
.github/workflows/sync-release-to-pg.yml
vendored
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
name: Merge release to pg
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- release # Trigger on push to the release branch
|
||||
|
||||
jobs:
|
||||
merge-release-to-pg:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout release branch
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
ref: release # Checkout the release branch
|
||||
|
||||
- name: Fetch all branches
|
||||
run: git fetch --all
|
||||
|
||||
- name: Checkout pg branch
|
||||
run: git checkout pg
|
||||
|
||||
- name: Get new commits from release
|
||||
id: get_commits
|
||||
run: |
|
||||
COMMITS=$(git log pg..release --oneline | awk '{print $1}')
|
||||
echo "COMMITS=\"$COMMITS\"" >> $GITHUB_ENV
|
||||
|
||||
- name: Merge commits one by one
|
||||
id: merge_commits
|
||||
run: |
|
||||
# Initialize an empty list for conflicted commits
|
||||
conflicted_commits=()
|
||||
|
||||
# Convert the string of commits to an array
|
||||
IFS=' ' read -r -a commit_array <<< "$COMMITS"
|
||||
|
||||
# Loop through each commit
|
||||
for commit in "${commit_array[@]}"; do
|
||||
echo "Merging commit $commit"
|
||||
git cherry-pick $commit || {
|
||||
echo "Conflict detected with commit $commit"
|
||||
conflicted_commits+=($commit)
|
||||
git cherry-pick --abort
|
||||
}
|
||||
done
|
||||
|
||||
# Save conflicted commits to environment variable
|
||||
echo "CONFLICTED_COMMITS=\"${conflicted_commits[@]}\"" >> $GITHUB_ENV
|
||||
|
||||
- name: Push changes
|
||||
if: success() && steps.merge_commits.outputs.CONFLICTED_COMMITS == ''
|
||||
run: |
|
||||
git push origin pg
|
||||
|
||||
- name: Notify on merge conflicts
|
||||
if: steps.merge_commits.outputs.CONFLICTED_COMMITS != ''
|
||||
env:
|
||||
REPOSITORY_URL: ${{ github.repositoryUrl }}
|
||||
run: |
|
||||
# Prepare the message for Slack
|
||||
message="Merge conflict detected while merging release into pg branch. Conflicted commits:\n"
|
||||
for commit in $CONFLICTED_COMMITS; do
|
||||
commit_url="$REPOSITORY_URL/commit/$commit"
|
||||
message+="$commit_url\n"
|
||||
done
|
||||
|
||||
# Send the message to Slack
|
||||
# This unwieldy horror of a sed command, converts standard Markdown links to Slack's unwieldy link syntax.
|
||||
slack_message="$(echo "$message" | sed -E 's/\[([^]]+)\]\(([^)]+)\)/<\2|\1>/g')"
|
||||
|
||||
# This is the ChannelId of the proj postgres channel.
|
||||
body="$(jq -nc \
|
||||
--arg channel C06Q3A97USE \
|
||||
--arg text "$slack_message" \
|
||||
'$ARGS.named'
|
||||
)"
|
||||
|
||||
curl --version
|
||||
curl -v https://slack.com/api/chat.postMessage \
|
||||
--header 'Authorization: Bearer ${{ secrets.SLACK_APPSMITH_ALERTS_TOKEN }}' \
|
||||
--header 'Content-Type: application/json; charset=utf-8' \
|
||||
--data-raw "$body"
|
||||
Loading…
Reference in New Issue
Block a user