mirror of
				https://github.com/openimsdk/open-im-server.git
				synced 2025-10-31 08:29:33 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			69 lines
		
	
	
		
			2.5 KiB
		
	
	
	
		
			YAML
		
	
	
	
	
	
			
		
		
	
	
			69 lines
		
	
	
		
			2.5 KiB
		
	
	
	
		
			YAML
		
	
	
	
	
	
| # Copyright © 2023 OpenIM open source community. All rights reserved.
 | |
| #
 | |
| # Licensed under the Apache License, Version 2.0 (the "License");
 | |
| # you may not use this file except in compliance with the License.
 | |
| # You may obtain a copy of the License at
 | |
| #
 | |
| #     http://www.apache.org/licenses/LICENSE-2.0
 | |
| #
 | |
| # Unless required by applicable law or agreed to in writing, software
 | |
| # distributed under the License is distributed on an "AS IS" BASIS,
 | |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | |
| # See the License for the specific language governing permissions and
 | |
| # limitations under the License.
 | |
| 
 | |
| name: Github Robot for Cherry Pick On Comment
 | |
| 
 | |
| on:
 | |
|   issue_comment:
 | |
|     types: [created]
 | |
| 
 | |
| jobs:
 | |
|   cherry-pick:
 | |
|     name: Cherry Pick
 | |
|     if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/cherry-pick')
 | |
|     runs-on: ubuntu-latest
 | |
| 
 | |
|     steps:
 | |
|       - name: Checkout the latest code
 | |
|         uses: actions/checkout@v4
 | |
|         with:
 | |
|           token: ${{ secrets.BOT_GITHUB_TOKEN }}
 | |
|           fetch-depth: 0 # To ensure all history is available for cherry-picking
 | |
| 
 | |
|       - name: Automatic Cherry Pick
 | |
|         uses: vendoo/gha-cherry-pick@v1
 | |
|         with:
 | |
|           # Assuming the cherry-pick commit SHA is passed in the comment like '/cherry-pick sha'
 | |
|           commit-sha: ${{ github.event.comment.body }}
 | |
|         env:
 | |
|           GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
 | |
| 
 | |
|       - name: Create a new branch for PR
 | |
|         run: |
 | |
|           PR_BRANCH="cherry-pick-${GITHUB_SHA}-to-${{ github.base_ref }}"
 | |
|           git checkout -b $PR_BRANCH
 | |
|           git push origin $PR_BRANCH
 | |
|         env:
 | |
|           GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
 | |
| 
 | |
|       - name: Create Pull Request
 | |
|         uses: actions/github-script@v5
 | |
|         with:
 | |
|           script: |
 | |
|             const prTitle = "Cherry-pick to ${{ github.base_ref }}"
 | |
|             const prBody = "Automated cherry-pick of ${{ github.event.comment.body }}\n\n/cc @kubbot"
 | |
|             const base = "${{ github.base_ref }}"
 | |
|             const head = "cherry-pick-${{ github.sha }}-to-${{ github.base_ref }}"
 | |
|             const createPr = await github.rest.pulls.create({
 | |
|               owner: context.repo.owner,
 | |
|               repo: context.repo.repo,
 | |
|               title: prTitle,
 | |
|               body: prBody,
 | |
|               head: head,
 | |
|               base: base,
 | |
|               maintainer_can_modify: true, // Allows maintainers to edit the PR
 | |
|             })
 | |
|         env:
 | |
|           GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
 |