This commit is contained in:
Dave Horton
2023-04-10 09:08:54 -04:00
parent 1126ea827f
commit 92da5518eb

View File

@@ -19,21 +19,25 @@ jobs:
uses: actions/checkout@v3
- name: prepare tag
id: prepare_tag
run: |
export IMAGE_ID=jambonz/$IMAGE_NAME
IMAGE_ID=jambonz/$IMAGE_NAME
# Strip git ref prefix from version
export VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "main" ] && export VERSION=latest
[ "$VERSION" == "main" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
echo "::set-output name=image_id::$IMAGE_ID"
echo "::set-output name=version::$VERSION"
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
@@ -45,10 +49,7 @@ jobs:
with:
context: .
push: true
tags: ${{ env.IMAGE_ID }}:${{ env.VERSION }}
tags: ${{ steps.prepare_tag.outputs.image_id }}:${{ steps.prepare_tag.outputs.version }}
build-args: |
GITHUB_REPOSITORY=$GITHUB_REPOSITORY
GITHUB_REF=$GITHUB_REF
env:
IMAGE_ID: ${{ env.IMAGE_ID }}
VERSION: ${{ env.VERSION }}