6
6
branches :
7
7
description : ' Dev branch names to update from master'
8
8
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
14
9
schedule :
15
10
- cron : " 0 5 * * 3" # workflow runs every Wednesday at 5 AM UTC
16
11
@@ -35,14 +30,18 @@ jobs:
35
30
uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
36
31
with :
37
32
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'
39
38
- name : Config Git
40
39
run : |
41
40
git config --local user.email svc-api-experience-integrations-escalation@mongodb.com
42
41
git config --local user.name svc-apix-bot
43
42
44
- - name : Rebase branch with master
45
- id : rebase -check
43
+ - name : Merge branch with master
44
+ id : merge -check
46
45
run : |
47
46
echo "Updating branch: ${{ matrix.branch }}"
48
47
@@ -55,49 +54,68 @@ jobs:
55
54
git fetch origin ${{ matrix.branch }}
56
55
git checkout -B ${{ matrix.branch }} origin/${{ matrix.branch }}
57
56
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}"
60
62
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}"
72
67
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
74
76
exit 1
75
77
fi
76
78
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}"
82
94
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}"
85
96
fi
86
97
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
90
101
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
+ }
99
117
100
- slack-notification :
118
+ slack-notification-failure :
101
119
needs : update-branches
102
120
if : ${{ !cancelled() && needs.update-branches.result == 'failure' }}
103
121
runs-on : ubuntu-latest
@@ -116,7 +134,7 @@ jobs:
116
134
"type": "section",
117
135
"text": {
118
136
"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>"
120
138
}
121
139
}
122
140
]
0 commit comments