【问题标题】:Github Actions / Extract TicketID from branch nameGithub Actions / 从分支名称中提取 TicketID
【发布时间】:2020-12-16 12:01:34
【问题描述】:

您目前可以通过以下方式设置环境变量:

  - name: Configure Environment Variables
    uses: allenevans/set-env@v1.0.0
    with:
      CDN_PATH: app-foo/${{ github.run_id }}
      CDN_URL: 'https://cdn.mycompany.com'
      JIRA_TICKET_ID: ${{ match(github.ref, ...) }} # How can I extract a string from a branch name?

如何从分支名称中提取字符串?

JIRA_TICKET_ID: ${{ match(github.ref, ...) }}

【问题讨论】:

    标签: regex github yaml github-actions


    【解决方案1】:

    我不相信 github 操作中有内置函数可以做到这一点。但是你可以在你的行动之前运行一个步骤来为你获取 jira 票。

    注意:您需要将 sed 正则表达式修改为获取票证的正则表达式。现在它只从 ref 中获取分支名称

    - id: getjiraticket
      run:  echo "::set-output name=jiraticketid::`echo "${{ github.ref }}" | sed 's/.*\///'`"
    - name: Configure Environment Variables
      uses: allenevans/set-env@v1.0.0
      with:
        CDN_PATH: app-foo/${{ github.run_id }}
        CDN_URL: 'https://cdn.mycompany.com'
        JIRA_TICKET_ID: ${{ steps.getjiraticket.outputs.jiraticketid }}
    

    【讨论】:

    • 谢谢!我一整天都在努力实现语法,它工作得很好!
    猜你喜欢
    • 2020-12-29
    • 2022-06-21
    • 1970-01-01
    • 2018-05-26
    • 2023-03-26
    • 1970-01-01
    • 2020-01-21
    • 2022-01-08
    • 1970-01-01
    相关资源
    最近更新 更多