GitHub Actions 令牌工作流程未设置错误

huangapple go评论62阅读模式
英文:

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  

image of error

答案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

huangapple
  • 本文由 发表于 2023年2月19日 10:19:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/75497613.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定