如何解决如何在发布时在github中获取目标分支
我有一个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.event.release.target_commitish
env变量中找到。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。