-
Notifications
You must be signed in to change notification settings - Fork 0
76 lines (64 loc) · 2.37 KB
/
automerge.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
name: Auto merge
on:
schedule:
- cron: '0 */12 * * *'
workflow_dispatch:
jobs:
auto_merge:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
token: ${{ secrets.COMMIT_TOKEN }}
- name: Set up Git user
run: |
git config --global user.email "ansulagrawal9@gmail.com"
git config --global user.name "Ansul Agrawal"
- name: Generate branch name
id: branch_name
run: |
BRANCH_NAME="auto-merge-$(date +'%Y-%m-%d-%H-%M-%S')"
echo "branch=$BRANCH_NAME" >> $GITHUB_OUTPUT
- name: Checkout new branch
run: |
git checkout -b "${{ steps.branch_name.outputs.branch }}"
- name: Modify last update file
run: |
echo "$(date '+%Y-%m-%dT%H:%M:%SZ')" > LAST_UPDATED
- name: Commit changes
run: |
git add LAST_UPDATED
arr=(
"chore(bot): 😂 auto merge"
"chore(bot): 😱 auto merge"
"chore(bot): 👿 auto merge"
"chore(bot): 💩 auto merge"
"chore(bot): 🙏 auto merge"
"chore(bot): 🙈 auto merge"
"chore(bot): 🐐 auto merge"
"chore(bot): 🤖 auto merge"
"chore(bot): 🟩 auto merge"
"chore(bot): 👻 auto merge"
)
rand=$((RANDOM % ${#arr[@]}))
git commit -m "${arr[$rand]}"
- name: Push the new branch
env:
BRANCH_NAME: ${{ steps.branch_name.outputs.branch }}
COMMIT_TOKEN: ${{ secrets.COMMIT_TOKEN }}
GITHUB_TOKEN: ${{ secrets.COMMIT_TOKEN }}
run: |
git push -u https://$COMMIT_TOKEN@github.com/${{ github.repository }} "$BRANCH_NAME"
- name: Create pull request with gh
env:
BRANCH_NAME: ${{ steps.branch_name.outputs.branch }}
GH_TOKEN: ${{ secrets.COMMIT_TOKEN }}
run: |
gh pr create --title "Auto Merge PR" --body "This PR contains an auto merge for the changes." --base main --head "$BRANCH_NAME" --repo "${{ github.repository }}"
- name: Merge PR using gh
env:
BRANCH_NAME: ${{ steps.branch_name.outputs.branch }}
GH_TOKEN: ${{ secrets.COMMIT_TOKEN }}
run: |
gh pr merge "$BRANCH_NAME" --squash --delete-branch --repo "${{ github.repository }}"