Github Actions是否有DRY方式在多个作业步骤中计算和共享值?
在下面的工作流程yml文件中,回显$ {GITHUB_REF} | cut -d'/'-f3`-$ {GITHUB_SHA}会分多个步骤重复。
name: Test, Build and Deploy
on:
push:
branches:
- master
jobs:
build_and_push:
name: Build and Push
runs-on: ubuntu-latest
steps:
- name: Docker Build
uses: "actions/docker/cli@master"
with:
args: build . --file Dockerfile -t cflynnus/blog:`echo ${GITHUB_REF} | cut -d'/' -f3`-${GITHUB_SHA}
- name: Docker Tag Latest
uses: "actions/docker/cli@master"
with:
args: tag cflynnus/blog:`echo ${GITHUB_REF} | cut -d'/' -f3`-${GITHUB_SHA} cflynnus/blog:latest
Run Code Online (Sandbox Code Playgroud)