我正在 GitHub 中创建一个工作流程,该工作流程创建并使用 Docker 镜像。因此,我使用此 docker 镜像的全局环境变量启动了我的工作流程文件,该变量对于我的工作流程中的所有作业都是可见的:
name: continuous integration
on:
push:
branches:
- '**'
env:
IMAGE: docker.pkg.github.com/${{ github.repository }}/jactor-persistence:${{ github.sha }}
我想用头部提交的短sha替换${{ github.sha }}
,与以下命令的结果相同git rev-parse --short头
这可能吗?
最佳答案
正如 VonC 提到的,您可以在上一步中自己计算字符串。
- name: Set outputs
id: vars
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Check outputs
run: echo ${{ steps.vars.outputs.sha_short }}
关于git - 如何获取github工作流程的短sha?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59810838/