我的分行名稱是AKA-2120
我用它作為作業來獲取分支名稱。
extract_branch_name:
runs-on: ubuntu-latest
steps:
- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
id: extract_branch
outputs:
branch: ${{ steps.extract_branch.outputs.branch }}
但我真正需要的輸出是aka2120
有沒有辦法洗掉特殊字符并降低分支名稱?
uj5u.com熱心網友回復:
有幾種方法可以解決您的問題。一種方法是使用 Marketplace 中的現有操作:
- uses: mad9000/actions-find-and-replace-string@2
id: findandreplace
with:
source: ${{ github.ref }}
find: '-'
replace: ''
- uses: ASzc/change-string-case-action@v2
id: lowercase
with:
string: ${{ steps.findandreplace.outputs.value }}
- name: Get the above output
run: echo "The replaced value is ${{ steps.lowercase.outputs.lowercase }}"
如果您只想要 bash 公式,那將起作用:
echo ${GITHUB_REF#refs/heads/} | tr "[:upper:]" "[:lower:]" | sed -e 's/-//g'
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/443663.html
上一篇:為什么會產生一個空的合并提交
