docs: correct ONI tutorial metadata and examples #3
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Enable Auto Merge | |
| on: | |
| pull_request_target: | |
| types: [opened, synchronize, reopened, ready_for_review] | |
| branches: | |
| - main | |
| - master | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| jobs: | |
| enable: | |
| # 只对仓库所有者在本仓库内创建的 PR 自动合并,外部贡献仍需人工审核。 | |
| if: >- | |
| ${{ | |
| !github.event.pull_request.draft && | |
| github.event.pull_request.head.repo.full_name == github.repository && | |
| github.event.pull_request.user.login == github.repository_owner | |
| }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Enable auto-merge after checks pass | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const pr = context.payload.pull_request; | |
| try { | |
| await github.graphql( | |
| ` | |
| mutation EnableAutoMerge($pullRequestId: ID!) { | |
| enablePullRequestAutoMerge( | |
| input: { | |
| pullRequestId: $pullRequestId | |
| mergeMethod: SQUASH | |
| } | |
| ) { | |
| pullRequest { number } | |
| } | |
| } | |
| `, | |
| { pullRequestId: pr.node_id } | |
| ); | |
| core.info(`Auto-merge enabled for PR #${pr.number}.`); | |
| } catch (error) { | |
| core.warning(`Failed to enable auto-merge: ${error.message}`); | |
| } |