github 操作工作流程中的环境自动批准不起作用

问题描述 投票:0回答:1

我使用

environment
viz
item1,item3,item4
和审批者作为参与者名称
mohtashims

对 GitHub 操作进行手动审批设置

下面是我的工作流程,我希望演员

mohtashims
自动批准环境
item1
item3
upload
工作矩阵。

我尝试使用这里的解决方案:https://github.com/activescott/automate-environment-deployment-approval

但是,如下面的快照所示,它不会自动批准,而是等待参与者手动批准

mohtashims

我看到一条警告消息如下:

auto_approve
Node.js 16 actions are deprecated. Please update the following actions to use Node.js 20: activescott/[email protected]. For more information see: https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/.

但是正如您在下面的快照中看到的,我尝试了 NodeJS 版本 20。我也不确定这是否是功能不起作用的原因。

还清楚地写着:

auto_approve
Approved deployment to item1 triggered by mohtashims for run Update main.yml.
auto_approve
Approved deployment to item3 triggered by mohtashims for run Update main.yml.

但没有获得自动批准。

这是我的工作流程文件:

on: push
jobs:
  matrix:
    outputs:
      matrix: ${{ steps.gen-matrix.outputs.matrix }}
    runs-on: windows-latest
    steps:
      - id: gen-matrix
        run: |
          $envList = "item1_pom item2 item3_xml item4_txt" -split ' '
          $unique_envList = @()
          foreach ($i in $envList) {
            if ($i -like '*_*') {
              $unique_envList += ($i -split '_')[0]
            }
          }
          $matrix = ConvertTo-Json $unique_envList -Compress
          echo "matrix=$matrix" >> "$env:GITHUB_OUTPUT"
  auto_approve:
    needs: matrix
    runs-on: windows-latest
    steps:

      - name: Setup Node.js
        uses: actions/[email protected]
        with:
          node-version: 20
          
          
      - name: Auto Approve Deploys
        # you can use any @vN.N.N tag from https://github.com/activescott/automate-environment-deployment-approval/releases
        uses: activescott/[email protected]
        with:
          github_token: ${{ secrets.GH_TOKEN_FOR_AUTO_APPROVING_DEPLOYS }}
          environment_allow_list: |
            item1
            item3
          # The below automatically approves dependabot and anything submitted by the Github user with login "activescott"
          actor_allow_list: |
            dependabot[bot]
            mohtashims
            
          
  upload:
    needs: [matrix, auto_approve]
    runs-on: windows-latest
    environment: ${{ matrix.environment }}
    strategy:
      matrix:
        environment: ${{ fromJson(needs.matrix.outputs.matrix) }}
    steps:
      - run: echo '${{ matrix.environment }}'

我错过了什么吗?请推荐。

github github-actions environment github-for-windows
1个回答
0
投票

尽管您已更新工作流程以使用 Node.js 版本 20,但警告表明外部 GitHub Action 可能仍在使用已弃用的 Node.js 版本。这可能不会直接影响自动批准功能,但值得解决以避免将来出现潜在问题。
确保最新版本的

activescott/automate-environment-deployment-approval
与 Node.js 20 兼容:它自己的
publish
工作流程
使用... Node.js 16.x.

验证

GH_TOKEN_FOR_AUTO_APPROVING_DEPLOYS
是否具有批准部署所需的权限。令牌应具有
workflow
environment
权限

关于

automate-environment-deployment-approval
Action 或其配置,主要错误消息是:

运行

'Update main.yml' ()
有待批准的部署,但它不是允许的环境:
'item4'

允许的环境有:
'[ 'item1', 'iteam3' ]'
并在
environment_allow_list
输入中指定

这应该意味着 GitHub Actions 工作流程已触发名为“item4”的环境的部署,但“item4”未包含在工作流程配置中定义的

environment_allow_list
中。该列表充当过滤器,指定允许
activescott/automate-environment-deployment-approval
操作自动批准哪些环境。

如果您希望自动批准“item4”部署,则需要将“item4”添加到

environment_allow_list
。如果“item4”不意味着自动批准,则系统正在正确等待手动批准部署到该环境。

© www.soinside.com 2019 - 2024. All rights reserved.