V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
alanhe421
V2EX  ›  程序员

GitHub action 中如何获取输入参数值?

  •  
  •   alanhe421 ·
    alanhg · 2021-06-13 23:44:36 +08:00 · 1539 次点击
    这是一个创建于 1018 天前的主题,其中的信息可能已经有所发展或是发生改变。
    name: 'Repo Star Count'
    description: 'Get count of Github repository stars'
    inputs:
      repoPath:
        description: 'Repository Path'
        required: false
        default: ${{github.repository}}
    outputs:
      stars:
        description: "Repo Stars"
        value: ${{ steps.repo-stars.outputs.stars }}
    runs:
      using: composite
      steps:
        - id: repo-stars
          run: |
            STARS=`curl -s 'https://api.github.com/repos/${{env.INPUT_REPOPATH}}?page=$i&per_page=100' | jq .stargazers_count`
            echo "::set-output name=stars::$STARS"
          shell: bash
    branding:
      icon: 'award'
      color: 'green'
    
    

    代码如上,获取的 INPUT_REPOPATH 为空,按照官网所说为环境变量-INPUT_参数名字进行获取,但是却没拿到,姿势不对?

    2 条回复    2021-06-14 09:54:37 +08:00
    alanhe421
        1
    alanhe421  
    OP
       2021-06-13 23:56:08 +08:00
    解决了,但是按照官方的说法没有解决,说的是 env 也可以取到。。BUT,不行。

    ${{ inputs.repoPath }} 可以取到值。
    Rhilip
        2
    Rhilip  
       2021-06-14 09:54:37 +08:00
    应该是不用写 env. 这个 prefix 的,直接 "$INPUT_FOO" 这种写法,
    因为 ${{ env.foo }} 这种写法是给挂在 envs: 下面的变量准备的
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2699 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 15:34 · PVG 23:34 · LAX 08:34 · JFK 11:34
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.