Sha*_*vel 5 github access-token github-actions github-secret
我有一个私有存储库,我正在尝试将 python-semantic-release 添加到 GitHub Actions 中。
当尝试增加版本号时,我收到错误消息,指出我没有对存储库的写访问权限。我已经使用了 Github Classic PAT 和 Finegrained PAT,但两者都不起作用。我授予了所有回购权限只是为了确保我没有搞砸任何事情。
我还在 GitHub Actions 中回应了我的 Secrets.TOKEN,以确保它们也被正确调用。
即使我已生成具有存储库所有权限的访问令牌,为什么我仍会收到写入错误?
主.ymlname: Semantic Release
on:
push:
branches:
- main
jobs:
release:
runs-on: ubuntu-latest
concurrency: release
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Step 1 - Echo out a GitHub Actions Secret to the logs
run: |
echo "The GitHub Action Secret will be masked: "
echo ${{ secrets.TOKEN }}
echo "Trick to echo GitHub Actions Secret: "
echo ${{secrets.TOKEN}} | sed 's/./& /g'
echo ${{secrets.USERNAME}} | sed 's/./& /g'
- name: Print repository URL
run: |
echo $(git remote get-url origin)
- name: Python Semantic Release
uses: relekang/python-semantic-release@master
with:
github_token: ${{ secrets.TOKEN }}
repository_username: __token__
Run Code Online (Sandbox Code Playgroud)
pyproject.toml
[tool.semantic_release]
version_variable = "setup.py:__version__"
branch = "main"
upload_to_repository = false
Run Code Online (Sandbox Code Playgroud)
安装程序.py
from setuptools import setup
__version__ = "1.0.1"
setup(
name="pmp-otk",
version=__version__,
# And so on...!!!!!!
)
Run Code Online (Sandbox Code Playgroud)
调试日志
debug: * We fixed the damn bug ([`6d6667a`](https://github.com/***/pmp-otk-sandbox/commit/6d6667afde48fbd3cbdabaa048989379b7216ea9))')
warning: Changelog file not found: /github/workspace/CHANGELOG.md - creating it.
debug: update_additional_files()
Bumping with a patch version to 1.0.2
debug: set_new_version('1.0.2')
debug: Writing new version number: path=PosixPath('setup.py') pattern='__version__ *[:=] *["\\\'](\\d+\\.\\d+\\.\\d+(-beta\\.\\d+)?)["\\\']' num_matches=1
debug: set_new_version -> True
debug: commit_new_version('1.0.2')
debug: commit_new_version -> [main [64](https://github.com/shawnesquivel/pmp-otk-sandbox/actions/runs/4018206730/jobs/6903535852#step:6:65)d5a24] 1.0.2
debug: 2 files changed, 8 insertions(+), 1 deletion(-)
debug: create mode 100644 CHANGELOG.md
debug: tag_new_version('1.0.2')
debug: tag_new_version ->
Pushing new version
debug: get_hvcs()
debug: get_hvcs -> <class 'semantic_release.hvcs.Github'>
debug: get_hvcs()
debug: get_hvcs -> <class 'semantic_release.hvcs.Github'>
debug: push_new_version(, auth_token='***', owner='***', name='pmp-otk-sandbox', branch=main, domain='github.com')
error: Cmd('git') failed due to: exit code(128)
error: cmdline: git push ***github.com/***/pmp-otk-sandbox.git main
error: stderr: 'remote: Write access to repository not granted.
error: fatal: unable to access 'https://github.com/***/pmp-otk-sandbox.git/': The requested URL returned error: 403'
Run Code Online (Sandbox Code Playgroud)
我希望增加版本,并且不会出现写入访问问题。
提交示例:
git commit -m "fix: we fixed the damn bug"
Run Code Online (Sandbox Code Playgroud)
转到您的存储库设置Actions-> General,然后确保Actions permissions设置为Allow,并确保Workflow permissions设置为Read and write permissions。
如果该选项呈灰色,请转到您的组织设置Actions-> General,那里会有类似的设置。
另外,请确保在 yaml 文件中设置以下权限:
permissions:
contents: write
Run Code Online (Sandbox Code Playgroud)
Write 意味着读取和写入权限。
| 归档时间: |
|
| 查看次数: |
4412 次 |
| 最近记录: |