【发布时间】:2022-11-13 08:31:34
【问题描述】:
我的测试分支有一个分支保护,但我需要执行每个拉取请求合并一个操作以更新软件版本并在测试分支中提交。
即使有标签 - 力量出现错误:
INPUT_TAGGING_MESSAGE:
No tagging message supplied. No tag will be added.
INPUT_PUSH_OPTIONS: --force
remote: error: GH006: Protected branch update failed for refs/heads/test.
remote: error: Changes must be made through a pull request.
! [remote rejected] HEAD -> test (protected branch hook declined)
error: failed to push some refs to 'https://github.com/***/***'
Error: Invalid status code: 1
at ChildProcess.<anonymous> (/home/runner/work/_actions/stefanzweifel/git-auto-commit-action/v4/index.js:17:19)
at ChildProcess.emit (node:events:390:28)
at maybeClose (node:internal/child_process:1064:16)
at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5) {
code: 1
}
Error: Invalid status code: 1
at ChildProcess.<anonymous> (/home/runner/work/_actions/stefanzweifel/git-auto-commit-action/v4/index.js:17:19)
at ChildProcess.emit (node:events:390:28)
at maybeClose (node:internal/child_process:1064:16)
at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
我的工作流程操作:
name: Version Update
on:
pull_request:
branches:
- master
- test
types: [closed]
jobs:
version_update:
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true
steps:
- uses: shivammathur/setup-php@15c43e89cdef867065b0213be354c2841860869e
with:
php-version: '8.1'
- name: Get branch name
id: branch-name
uses: tj-actions/branch-names@v6
- uses: actions/checkout@v3
with:
ref: ${{ steps.branch-name.outputs.base_ref_branch }}
- name: Copy .env
run: php -r "file_exists('.env') || copy('.env.example', '.env');"
- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Generate key
run: php artisan key:generate
- name: Update Patch Version
if: steps.branch-name.outputs.current_branch != 'test'
run: php artisan version:patch
- name: Update Minor Version
if: steps.branch-name.outputs.current_branch == 'test'
run: php artisan version:minor
- name: Update Timestamp
run: php artisan version:timestamp
- name: Update Commit
run: php artisan version:absorb
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "version: update patch"
branch: ${{ steps.branch-name.outputs.base_ref_branch }}
push_options: '--force'
【问题讨论】:
-
推送时消息的剩余部分是什么?通常,您会看到原因为什么那里。
-
错误消息是:“必须通过拉取请求进行更改。”
-
我猜这必须为分支设置某个地方。
-
这些 GitHub 设置对我来说很合适,但我不是 GitHub 专家。请注意,您无法设置任何内容吉特为此,这完全是在 Git 上中心事情的一面。
标签: github github-actions git-branch