【问题标题】:How to avoid setting ACTIONS_ALLOW_UNSECURE_COMMANDS for setup-python?如何避免为 setup-python 设置 ACTIONS_ALLOW_UNSECURE_COMMANDS?
【发布时间】:2021-02-22 23:45:02
【问题描述】:

Github Actions 的 actions/setup-python 步骤未成功,因为使用了 ::set-env:::add-path:,因为被认为不安全 (https://github.blog/changelog/2020-10-01-github-actions-deprecating-set-env-and-add-path-commands) 而被阻止。

为此步骤设置ACTIONS_ALLOW_UNSECURE_COMMANDS=true 环境变量成功。

如何避免允许不安全的命令成功运行 Python 构建?


在带有 Ubuntu 20.04 基础映像的定制 docker 中自托管运行器。链接到 GHE 服务器 v2.22.4。

在 Python 3.9.0 和 3.9.1 上都试过

工作流程文件:

name: CD testing
on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
    runs-on: [ Linux ]

    - uses: actions/checkout@v2

    - name: setup python
      uses: actions/setup-python@v2
      with:
        python-version: 3.9.0

    - name: execute py script
      run: |
        python -V
##[debug]Found tool in cache Python 3.9.1 x64
::set-env name=pythonLocation::/opt/hostedtoolcache/Python/3.9.1/x64
##[error]Unable to process command '::set-env name=pythonLocation::/opt/hostedtoolcache/Python/3.9.1/x64' successfully.
##[error]The `set-env` command is disabled. Please upgrade to using Environment Files or opt into unsecure command execution by setting the `ACTIONS_ALLOW_UNSECURE_COMMANDS` environment variable to `true`. For more information see: https://github.blog/changelog/2020-10-01-github-actions-deprecating-set-env-and-add-path-commands/
##[debug]System.Exception: The `set-env` command is disabled. Please upgrade to using Environment Files or opt into unsecure command execution by setting the `ACTIONS_ALLOW_UNSECURE_COMMANDS` environment variable to `true`. For more information see: https://github.blog/changelog/2020-10-01-github-actions-deprecating-set-env-and-add-path-commands/
##[debug]   at GitHub.Runner.Worker.SetEnvCommandExtension.ProcessCommand(IExecutionContext context, String line, ActionCommand command, ContainerInfo container)
##[debug]   at GitHub.Runner.Worker.ActionCommandManager.TryProcessCommand(IExecutionContext context, String input, ContainerInfo container)
::add-path::/opt/hostedtoolcache/Python/3.9.1/x64
##[error]Unable to process command '::add-path::/opt/hostedtoolcache/Python/3.9.1/x64' successfully.
##[error]The `add-path` command is disabled. Please upgrade to using Environment Files or opt into unsecure command execution by setting the `ACTIONS_ALLOW_UNSECURE_COMMANDS` environment variable to `true`. For more information see: https://github.blog/changelog/2020-10-01-github-actions-deprecating-set-env-and-add-path-commands/
##[debug]System.Exception: The `add-path` command is disabled. Please upgrade to using Environment Files or opt into unsecure command execution by setting the `ACTIONS_ALLOW_UNSECURE_COMMANDS` environment variable to `true`. For more information see: https://github.blog/changelog/2020-10-01-github-actions-deprecating-set-env-and-add-path-commands/
##[debug]   at GitHub.Runner.Worker.AddPathCommandExtension.ProcessCommand(IExecutionContext context, String line, ActionCommand command, ContainerInfo container)
##[debug]   at GitHub.Runner.Worker.ActionCommandManager.TryProcessCommand(IExecutionContext context, String input, ContainerInfo container)
::add-path::/opt/hostedtoolcache/Python/3.9.1/x64/bin
##[error]Unable to process command '::add-path::/opt/hostedtoolcache/Python/3.9.1/x64/bin' successfully.
##[error]The `add-path` command is disabled. Please upgrade to using Environment Files or opt into unsecure command execution by setting the `ACTIONS_ALLOW_UNSECURE_COMMANDS` environment variable to `true`. For more information see: https://github.blog/changelog/2020-10-01-github-actions-deprecating-set-env-and-add-path-commands/
##[debug]System.Exception: The `add-path` command is disabled. Please upgrade to using Environment Files or opt into unsecure command execution by setting the `ACTIONS_ALLOW_UNSECURE_COMMANDS` environment variable to `true`. For more information see: https://github.blog/changelog/2020-10-01-github-actions-deprecating-set-env-and-add-path-commands/
##[debug]   at GitHub.Runner.Worker.AddPathCommandExtension.ProcessCommand(IExecutionContext context, String line, ActionCommand command, ContainerInfo container)
##[debug]   at GitHub.Runner.Worker.ActionCommandManager.TryProcessCommand(IExecutionContext context, String input, ContainerInfo container)
::set-output name=python-version::3.9.1
##[debug]='3.9.1'
Successfully setup CPython (3.9.1)

【问题讨论】:

    标签: github-actions


    【解决方案1】:

    更新actions/setup-python,它在以前的版本中使用set-env

    - uses: actions/setup-python@v2
    

    到最新版本

    - uses: actions/setup-python@v2.2.1
    

    有一个bug - v2 没有使用最新版本。

    【讨论】:

      猜你喜欢
      • 2011-09-23
      • 2020-07-16
      • 2017-09-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-20
      • 2015-02-18
      • 2022-10-24
      相关资源
      最近更新 更多