Skip to content

Auto Compress Images #19

Auto Compress Images

Auto Compress Images #19

Workflow file for this run

name: 自动批准 PR
on:
pull_request_target:
types: [opened, synchronize, reopened, ready_for_review, labeled]
jobs:
auto-approve-and-merge:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Approve and Merge PR if Author is Specified User
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
run: |
# 指定允许自动批准和合并的用户名
ALLOWED_USER="github-actions[bot]"
# 检查 PR 作者是否为指定用户
if [[ "${{ github.event.pull_request.user.login }}" == "$ALLOWED_USER" ]]; then
echo "Author is $ALLOWED_USER, approving and merging PR."
# 执行自动批准
gh pr review ${{ github.event.pull_request.number }} --approve
# 执行自动合并并删除分支
gh pr merge ${{ github.event.pull_request.number }} --merge --delete-branch
else
echo "Author is not $ALLOWED_USER, skipping approval and merge."
fi
shell: bash