英文:
Github actions token workflow not set error
问题
你好,我目前正在编写一个工作流,用于在创建拉取请求时自动合并,但我卡在一个错误上,告诉我我的令牌未设置,具体来说是:2023-02-19T02:09:08.581Z ERROR environment variable GITHUB_TOKEN not set!。我已在我的存储库和设置选项卡中设置了所有令牌。任何帮助将不胜感激。
name: CI/CD
on:
pull_request:
branches: [master]
jobs:
super-linter:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Super-Linter
uses: github/super-linter@v4.10.1
with:
files: ${{ join(github.event.pull_request.changed_files, ',') }}
Merge:
runs-on: ubuntu-latest
needs: super-linter
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Merge pull requests
uses: pascalgn/automerge-action@v0.14.1
with:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
deploy:
runs-on: self-hosted
needs: Merge
steps:
- name: update code base
working-directory: /test_pipe/www/html
run: sudo git pull origin master
- name: restart
working-directory: /test_pipe/www/html
run: sudo systemctl restart nginx
英文:
Hello everyone I am currently writing a workflow to auto merge when a pull request is made but I am stuck at an error telling me my token is not set more specifically: 2023-02-19T02:09:08.581Z ERROR environment variable GITHUB_TOKEN not set!. I have set all my tokens in my repo and settings tab. Any help would be appreciated.
name: CI/CD
on:
pull_request:
branches: [ master ]
jobs:
super-linter:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Super-Linter
uses: github/super-linter@v4.10.1
with:
files: ${{ join(github.event.pull_request.changed_files, ',') }}
Merge:
runs-on: ubuntu-latest
needs: super-linter
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Merge pull requests
uses: pascalgn/automerge-action@v0.14.1
with:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
deploy:
runs-on: self-hosted
needs: Merge
steps:
#- uses: actions/checkout@v2 #this is used for if you want to push all source code into runner
- name: update code base
working-directory: /test_pipe/www/html
run: sudo git pull origin master
- name: restart
working-directory: /test_pipe/www/html
run: sudo systemctl restart nginx
答案1
得分: 0
pascalgn/automerge-action
接受 GITHUB_TOKEN
作为环境变量,而不是作为参数。因此应该是:
- name: 合并拉取请求
uses: pascalgn/automerge-action@v0.14.1
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
请参阅文档:https://github.com/pascalgn/automerge-action#usage
英文:
pascalgn/automerge-action
accepts GITHUB_TOKEN
as an env variable, not as an argument. So it should be:
- name: Merge pull requests
uses: pascalgn/automerge-action@v0.14.1
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
Refer to the documentation: https://github.com/pascalgn/automerge-action#usage
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论