Skip to content

Commit 3959606

Browse files
Update dependabot-merger.yml
1 parent 1caee00 commit 3959606

File tree

1 file changed

+52
-6
lines changed

1 file changed

+52
-6
lines changed

.github/workflows/dependabot-merger.yml

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,69 @@ jobs:
4545
echo "$PR_COUNT PR's to be merged: $PR_LIST"
4646
4747
- name: Merge PRs into new branch
48+
id: merge_prs
4849
run: |
4950
NEW_BRANCH="dependabot-test-${{ steps.datetime.outputs.date }}"
5051
git checkout $NEW_BRANCH
51-
PR_LIST=$(gh pr list --json number,headRefName --jq '.[] | "\(.number) \(.headRefName)"' | grep dependabot)
52-
PR_LIST=$(echo "$PR_LIST" | tr -d '\r')
53-
echo "::set-output name=numbers::$PR_LIST"
54-
while IFS= read -r line; do
55-
IFS=' ' read -r PR_NUMBER BRANCH_NAME <<< "$line"
52+
IFS=$'\n' read -r -a array <<< "${{ steps.pr_list.outputs.numbers }}"
53+
for item in "${array[@]}"; do
54+
IFS=' ' read -r PR_NUMBER BRANCH_NAME <<< "$item"
5655
echo "Merging PR #$PR_NUMBER from branch $BRANCH_NAME into $NEW_BRANCH..."
5756
git fetch origin $BRANCH_NAME
5857
git merge --no-commit --allow-unrelated-histories --strategy-option=theirs origin/$BRANCH_NAME
5958
echo "Pushing changes to $NEW_BRANCH..."
6059
git commit -m "Merged PR #$PR_NUMBER into $NEW_BRANCH"
6160
git push origin $NEW_BRANCH
62-
done <<< "$PR_LIST"
61+
done
62+
63+
# Generate the PR links and names for Slack message
64+
PR_LINKS=""
65+
for item in "${array[@]}"; do
66+
IFS=' ' read -r PR_NUMBER BRANCH_NAME <<< "$item"
67+
PR_LINKS+="\n• <https://github.com/BranchMetrics/ios-branch-deep-linking-attribution/pull/$PR_NUMBER|#$PR_NUMBER: PR Name here>"
68+
done
69+
70+
echo "::set-output name=pr_links::$PR_LINKS"
71+
6372

6473
- name: Merge process status
6574
run: |
6675
echo "Merging process completed successfully!"
6776
echo "New branch name: dependabot-test-${{ steps.datetime.outputs.date }}"
77+
78+
- name: Post to a Slack channel
79+
uses: slackapi/[email protected]
80+
with:
81+
channel-id: 'C04E69NEDAT'
82+
payload: |
83+
{
84+
"blocks": [
85+
{
86+
"type": "header",
87+
"text": {
88+
"type": "plain_text",
89+
"text": "New iOS Dependabot Testing Branch",
90+
"emoji": true
91+
}
92+
},
93+
{
94+
"type": "divider"
95+
},
96+
{
97+
"type": "section",
98+
"text": {
99+
"type": "mrkdwn",
100+
"text": "*Testing Branch: *<https://github.com/BranchMetrics/ios-branch-deep-linking-attribution/tree/dependabot-test-${{ steps.datetime.outputs.date }}|dependabot-test-${{ steps.datetime.outputs.date }}>"
101+
}
102+
},
103+
{
104+
"type": "section",
105+
"text": {
106+
"type": "mrkdwn",
107+
"text": "'${{ steps.merge_prs.outputs.pr_links }}'"
108+
}
109+
}
110+
]
111+
}
112+
env:
113+
SLACK_BOT_TOKEN: ${{ secrets.SLACK_SDK_BOT_TOKEN }}

0 commit comments

Comments
 (0)