【问题标题】:How to get target branch in github actions on release如何在发布时在 github 操作中获取目标分支
【发布时间】:2020-08-19 02:31:37
【问题描述】:

我有一个 github 操作,应该使用来自 github UI 的 tag_name 提供的发布版本更新当前分支。

除了目标分支的未知变量名之外,一切似乎都正常。

on:
  release:
    types: [created]

jobs:
  update-version:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2 # <-- I want the branch to match github release selected branch
      - name: Update version
        run: |
          tag_name=$(echo "${github.event.release.tag_name}" | sed -e 's/[]$.*[\^]/\\&/g' )
          sed -i "s/\"version\": \".*\",/\"version\": \"${tag_name}\",/" ./src/components/package.json
      - name: Commit Updated version.
        run: |
          git config --local user.email "action@github.com"
          git config --local user.name "GitHub Action"
          git add . && git commit -m "Bump version" -a
      - name: Push changes
        uses: ad-m/github-push-action@master
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}

【问题讨论】:

    标签: github-actions


    【解决方案1】:

    经过一番挖掘,我找到了解决方案。 分支名称在 github.event.release.target_commitish 环境变量中。

    【讨论】:

    • 这拯救了我的一天,谢谢!
    • @ManuElMagak 你的评论让我很开心 =) 谢谢你
    猜你喜欢
    • 2015-10-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-03
    • 2020-04-10
    • 2021-06-04
    • 2021-10-12
    • 2021-10-14
    相关资源
    最近更新 更多