Skip to content

Commit

Permalink
ud
Browse files Browse the repository at this point in the history
  • Loading branch information
mo3et committed Sep 13, 2024
1 parent 0f2d261 commit a01d18f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 66 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/del-bot-gen-branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Delete branch after PR merge by bot gen

on:
pull_request:
types:
- closed # 监听PR关闭事件(包括合并)

workflow_dispatch: # 手动触发工作流

jobs:
delete_branch:
if: ${{ github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'update-version-') && github.event.pull_request.user.login == 'github-actions[bot]' }} # 条件:PR已合并、分支以 'update-version-' 开头、PR发起者是 github-actions[bot]
runs-on: ubuntu-latest

steps:
- name: Set up Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Step 1: Delete the branch that was used for the PR
- name: Delete branch
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH_TO_DELETE: ${{ github.event.pull_request.head.ref }} # 使用env变量存储待删除的分支名称
run: |
if [ "$BRANCH_TO_DELETE" != "main" ]; then
git push origin --delete "$BRANCH_TO_DELETE"
echo "Branch '$BRANCH_TO_DELETE' deleted."
else
echo "Cannot delete 'main' branch."
67 changes: 1 addition & 66 deletions .github/workflows/upgrade-version-by-tag.yml
Original file line number Diff line number Diff line change
@@ -1,68 +1,3 @@
# name: Upgrade version by tag

# on:
# push:
# tags:
# - 'v*.*.*'

# jobs:
# upgrade_version:
# runs-on: ubuntu-latest
# steps:
# # Step 1: Checkout code
# - name: Checkout code
# uses: actions/checkout@v4
# with:
# repository: openimsdk/actions-test

# # Step 2: Set up Git
# - name: Set up Git
# run: |
# git config user.name "github-actions[bot]"
# git config user.email "github-actions[bot]@users.noreply.github.com"

# # Step 4: Add a remote pointing to the forked repository
# - name: Add fork remote
# run: |
# git remote add fork https://github.com/openimsdk/actions-test.git
# git fetch fork

# # # Step 3: Create a new branch
# # - name: Create new branch for version update
# # run: |
# # TAG_VERSION=${GITHUB_REF#refs/tags/}
# # BRANCH_NAME="update-version-${TAG_VERSION}"
# # git checkout -b $BRANCH_NAME

# # Step 4: Update version file
# - name: Update version file
# run: |
# TAG_VERSION=${GITHUB_REF#refs/tags/}
# echo "$TAG_VERSION" > version/version
# git add version/version
# git commit -m "Update version to $TAG_VERSION"

# # Step 5: Push the new branch
# - name: Push branch
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# run: |
# TAG_VERSION=${GITHUB_REF#refs/tags/}
# BRANCH_NAME="update-version-${TAG_VERSION}"
# git push fork $BRANCH_NAME

# # Step 6: Create Pull Request
# - name: Create Pull Request
# id: create_pr
# uses: peter-evans/create-pull-request@v7.0.1
# with:
# token: ${{ secrets.GITHUB_TOKEN }}
# # repository: openimsdk/actions-test
# branch: github-actions[bot]:$BRANCH_NAME
# base: main # Replace 'main' with your default branch if necessary
# title: "Update version to $TAG_VERSION"
# body: "This PR updates the version file to the new tag version $TAG_VERSION."

name: Upgrade version by tag

permissions:
Expand All @@ -72,7 +7,7 @@ permissions:
on:
push:
tags:
- 'v*.*.*' # 监听符合语义版本号的标签
- 'v*.*.*'

jobs:
upgrade_version:
Expand Down

0 comments on commit a01d18f

Please sign in to comment.