我正在尝试使用分支名称和github运行编号的组合作为我的github动作ci/cd进程中的图像标签
长话短说:我想将MODIFIED_BRANCH_NAME设置为环境变量,并在以后使用它
这是我的工作流文件
name: CI/CD mktplc-catalog
on:
push:
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
MODIFIED_BRANCH_NAME: # What goes here?
.
.
.
假设分支名称为feature/add-foo
,我需要将MODIFIED_BRANCH_NAME设置为feature-add-foo
我该怎么做?
您可以使用shell参数展开添加额外的步骤,如:
steps:
- name: Sets MODIFIED_BRANCH_NAME
env:
name: "${{env.BRANCH_NAME}}"
run: |
echo "MODIFIED_BRANCH_NAME=${name///-}" >> $GITHUB_ENV
此处测试https://github.com/mbiagetti/github-action-poc/pull/1
你可以用下面的代码测试shell的扩展:
>name=feature/add-foo
>MODIFIED_BRANCH_NAME=${name///-}
>echo $MODIFIED_BRANCH_NAME
feature-add-foo
更新对于多个工作要求,请查看此PR https://github.com/mbiagetti/github-action-poc/pull/2