Reputation: 2689
while doing build in github actions, I would like to set docker image name, based on branch name ie: base-name-develop
I tried for example:
image-name: my-service:$(ref=${GITHUB_REF%refs/heads/master};echo ${ref:=latest})
but it does not work, looks like is try to set name with all those $( etc. ;) instead of echo it
Upvotes: 2
Views: 969
Reputation: 2689
ok finally found solution
first we need to set variable:
- name: Extract Branch Name
shell: bash
run: |
branchName=${GITHUB_REF#refs/heads/}
if [ $branchName = 'develop' ]; then additionalImageName='-develop'; else additionalImageName=''; fi
echo "::set-output name=additionalImageName::$(echo $additionalImageName)"
id: extract_branch
and then in creating docker container step:
- name: docker
uses: VaultVulp/[email protected]
with:
image-name: test-service${{ steps.extract_branch.outputs.additionalImageName }}
looks like only way to use some variable in image-name is by using steps. Anyway it works well.
Upvotes: 3