Skip to content

Commit d5ea3ae

Browse files
authored
chore: Update dev branches with merge (#3474)
* don't create a PR and do merge * TEMPORARY to test * note for not pr * Revert "TEMPORARY to test" This reverts commit b6dc1c2. * skip-docs-notification no needed any more * add X icon to failed Slack messages * group clickable * TEMPORARY: test slack * project checks * remove continue-on-error * leftover * include tf setup * Revert "include tf setup" This reverts commit 5e12995. * set variable * fix oncall mentions * apix token * use token in checkout * revert test url
1 parent dd6c534 commit d5ea3ae

File tree

4 files changed

+63
-45
lines changed

4 files changed

+63
-45
lines changed

.github/workflows/generate-changelog.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
"type": "section",
4444
"text": {
4545
"type": "mrkdwn",
46-
"text": "*Automatic Changelog update failed* ${{ secrets.SLACK_ONCALL_TAG }} . <${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}}|Failed action >"
46+
"text": "*Automatic Changelog update failed* ${{ secrets.SLACK_ONCALL_TAG }} . <${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}}|Failed action >"
4747
}
4848
}
4949
]

.github/workflows/notify-docs-team.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66

77
jobs:
88
check:
9-
if: github.event.pull_request.draft == false && !contains(github.event.pull_request.labels.*.name, 'skip-docs-notification')
9+
if: github.event.pull_request.draft == false
1010
runs-on: ubuntu-latest
1111
outputs:
1212
files: ${{ steps.changes.outputs.files }}

.github/workflows/test-suite.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ jobs:
106106
"type": "section",
107107
"text": {
108108
"type": "mrkdwn",
109-
"text": "*Test Suite failed* ${{ secrets.SLACK_ONCALL_TAG }} <${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}}|View Failed Action>"
109+
"text": "*Test Suite failed* ${{ secrets.SLACK_ONCALL_TAG }} <${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}}|View Failed Action>"
110110
}
111111
}
112112
]

.github/workflows/update-dev-branches.yml

Lines changed: 60 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@ on:
66
branches:
77
description: 'Dev branch names to update from master'
88
default: '["CLOUDP-320243-dev-2.0.0"]'
9-
force-auto-resolve:
10-
description: 'Force auto-resolve conflicts by favoring master changes. Some changes in dev branch might be lost.'
11-
required: false
12-
default: false
13-
type: boolean
149
schedule:
1510
- cron: "0 5 * * 3" # workflow runs every Wednesday at 5 AM UTC
1611

@@ -35,14 +30,18 @@ jobs:
3530
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
3631
with:
3732
fetch-depth: 0
38-
33+
token: ${{ secrets.APIX_BOT_PAT }}
34+
- name: Install Go
35+
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5
36+
with:
37+
go-version-file: 'go.mod'
3938
- name: Config Git
4039
run: |
4140
git config --local user.email svc-api-experience-integrations-escalation@mongodb.com
4241
git config --local user.name svc-apix-bot
4342
44-
- name: Rebase branch with master
45-
id: rebase-check
43+
- name: Merge branch with master
44+
id: merge-check
4645
run: |
4746
echo "Updating branch: ${{ matrix.branch }}"
4847
@@ -55,49 +54,68 @@ jobs:
5554
git fetch origin ${{ matrix.branch }}
5655
git checkout -B ${{ matrix.branch }} origin/${{ matrix.branch }}
5756
58-
if git rebase origin/master; then
59-
echo "OK: Rebase completed successfully with no conflicts."
57+
# Check if there are commits in master not in dev branch
58+
commits_to_merge=$(git rev-list --count origin/${{ matrix.branch }}..origin/master)
59+
if [ "$commits_to_merge" -eq 0 ]; then
60+
echo "OK: No commits to merge from master. Branch is already up to date."
61+
echo "has-changes=false" >> "${GITHUB_OUTPUT}"
6062
else
61-
# Check if conflicts can be auto-resolved
62-
git rebase --abort
63-
if git rebase origin/master -X theirs; then
64-
if [ "${{ inputs.force-auto-resolve }}" = "true" ]; then
65-
echo "WARNING: Rebase conflicts detected but auto-resolved by favoring master changes because force-auto-resolve is true."
66-
else
67-
echo "ERROR: Rebase conflicts detected that can be auto-resolved by favoring master changes."
68-
echo "Manual review required to ensure no important changes are lost. Set force-auto-resolve to true to auto-resolve these conflicts."
69-
git rebase --abort
70-
exit 1
71-
fi
63+
echo "Found $commits_to_merge commits to merge from master."
64+
if git merge origin/master --no-edit; then
65+
echo "OK: Merge completed successfully with no conflicts."
66+
echo "has-changes=true" >> "${GITHUB_OUTPUT}"
7267
else
73-
echo "ERROR: Rebase conflicts detected that need manual intervention, they can't be auto-resolved."
68+
echo "ERROR: Merge conflicts detected. Manual intervention required:"
69+
echo "1. Perform a manual merge of master into ${{ matrix.branch }}"
70+
echo "2. Resolve all conflicts manually"
71+
echo "3. Add a bypass in dev branch ruleset settings to allow direct push to ${{ matrix.branch }}"
72+
echo "4. Push changes directly to ${{ matrix.branch }} (DO NOT create a PR)"
73+
echo "5. Remove the bypass from ruleset settings"
74+
echo "NOTE: Do not create a PR - squashed commits will cause the same conflicts to appear again in future updates"
75+
git merge --abort
7476
exit 1
7577
fi
7678
fi
77-
78-
# Check if there are any changes between rebased branch and original remote branch
79-
if git diff --quiet origin/${{ matrix.branch }} HEAD; then
80-
echo "No changes detected between rebased branch and original remote branch. PR would not introduce any changes."
81-
echo "has-changes=false" >> "${GITHUB_OUTPUT}"
79+
80+
- name: Push updated branch
81+
if: steps.merge-check.outputs.has-changes == 'true'
82+
run: |
83+
echo "Pushing updated branch ${{ matrix.branch }} to remote"
84+
git push origin ${{ matrix.branch }}
85+
86+
- name: Project check
87+
if: steps.merge-check.outputs.has-changes == 'true'
88+
id: project-check
89+
env:
90+
MONGODB_ATLAS_PREVIEW_PROVIDER_V2_ADVANCED_CLUSTER: "true"
91+
run: |
92+
if make tools build lint test; then
93+
echo "slack-text=✅ Dev branch \`${{ matrix.branch }}\` merged and pushed with latest changes from master. ${{ secrets.SLACK_ONCALL_TAG }} <${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}}|View Action>" >> "${GITHUB_OUTPUT}"
8294
else
83-
echo "Changes detected between rebased branch and original remote branch. PR will introduce changes."
84-
echo "has-changes=true" >> "${GITHUB_OUTPUT}"
95+
echo "slack-text=⚠️ Dev branch \`${{ matrix.branch }}\` merged and pushed. This is prefered even if checks failed as there were no merge conflicts. Project checks must be fixed. ${{ secrets.SLACK_ONCALL_TAG }} <${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}}|View Action>" >> "${GITHUB_OUTPUT}"
8596
fi
8697
87-
- name: Create pull request
88-
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e
89-
if: steps.rebase-check.outputs.has-changes == 'true'
98+
- name: Send Slack notification
99+
if: steps.merge-check.outputs.has-changes == 'true'
100+
uses: slackapi/slack-github-action@b0fa283ad8fea605de13dc3f449259339835fc52
90101
with:
91-
token: ${{ secrets.APIX_BOT_PAT }}
92-
title: "chore: Update ${{ matrix.branch }} from master"
93-
commit-message: "Update ${{ matrix.branch }} from master"
94-
delete-branch: true
95-
branch: update-${{ matrix.branch }}-from-master
96-
base: ${{ matrix.branch }}
97-
body: "Automated update of `${{ matrix.branch }}` branch with latest changes from master branch."
98-
labels: "skip-docs-notification"
102+
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
103+
webhook-type: incoming-webhook
104+
payload: |
105+
{
106+
"text": "Dev branch updated",
107+
"blocks": [
108+
{
109+
"type": "section",
110+
"text": {
111+
"type": "mrkdwn",
112+
"text": "${{ steps.project-check.outputs.slack-text }}"
113+
}
114+
}
115+
]
116+
}
99117
100-
slack-notification:
118+
slack-notification-failure:
101119
needs: update-branches
102120
if: ${{ !cancelled() && needs.update-branches.result == 'failure' }}
103121
runs-on: ubuntu-latest
@@ -116,7 +134,7 @@ jobs:
116134
"type": "section",
117135
"text": {
118136
"type": "mrkdwn",
119-
"text": "*Update dev branches failed* ${{ secrets.SLACK_ONCALL_TAG }} <${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}}|View Failed Action>"
137+
"text": "*Update dev branches failed* ${{ secrets.SLACK_ONCALL_TAG }} <${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}}|View Failed Action>"
120138
}
121139
}
122140
]

0 commit comments

Comments
 (0)