Skip to content

Commit

Permalink
ci(workflows): fix tags for deploy-docker workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoprow committed Jun 19, 2024
1 parent 22cd1b5 commit bf2838b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 19 deletions.
1 change: 1 addition & 0 deletions .github/workflows/deploy-docker-all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ on:
- 'bpdm-**'
branches:
- main
pull_request:
jobs:
build-docker-pool:
uses: ./.github/workflows/deploy-docker.yaml
Expand Down
27 changes: 8 additions & 19 deletions .github/workflows/deploy-docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,13 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- uses: dorny/paths-filter@v3
id: changes
with:
filters: |
apps:
- 'pom.xml'
- 'bpdm-**'
- name: Extract Maven Project Version
if: steps.changes.outputs.apps == 'true'
id: pomVersion
run: |
POM_VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' -B --non-recursive exec:exec)
echo "version=$POM_VERSION" >> $GITHUB_OUTPUT
- name: Parse semantic version from string
if: steps.changes.outputs.apps == 'true'
id: semVer
uses: release-kit/semver@v2
with:
Expand All @@ -76,15 +66,16 @@ jobs:
- name: Create Docker Tags
id: dockerTags
run: |
SUFFIX="${{ steps.semVer.outputs.prerelease == 'SNAPSHOT' && '-SNAPSHOT' || '' }}"
LATEST="latest$SUFFIX"
FULL_IMAGE_NAME="${{ env.IMAGE_NAMESPACE }}/${{ env.IMAGE_NAME }}"
SUFFIX="${{ steps.semVer.outputs.prerelease == 'SNAPSHOT' && '-snapshot' || '' }}"
MAJOR="${{ steps.semVer.outputs.major }}"
MINOR="${MAJOR}.${{ steps.semVer.outputs.minor }}"
PATCH="${MINOR}.${{ steps.semVer.outputs.patch }}"
MAJOR_VER="${MAJOR}${SUFFIX}"
MINOR_VER="${MINOR}${SUFFIX}"
PATCH_VER="${PATCH}${SUFFIX}"
echo "tags=${LATEST},${MAJOR_VER},${MINOR_VER},${PATCH_VER}" >> $GITHUB_OUTPUT
LATEST_TAG="${FULL_IMAGE_NAME}:latest${SUFFIX}"
MAJOR_TAG="${FULL_IMAGE_NAME}:${MAJOR}${SUFFIX}"
MINOR_TAG="${FULL_IMAGE_NAME}:${MINOR}${SUFFIX}"
PATCH_TAG="${FULL_IMAGE_NAME}:${PATCH}${SUFFIX}"
echo "tags=${LATEST_TAG},${MAJOR_TAG},${MINOR_TAG},${PATCH_TAG}" >> $GITHUB_OUTPUT
- name: DockerHub login
uses: docker/login-action@v3
Expand All @@ -93,16 +84,14 @@ jobs:
password: ${{ secrets.DOCKER_HUB_TOKEN }}

- name: Build and push
if: steps.changes.outputs.apps == 'true'
uses: docker/build-push-action@v5
with:
context: .
push: true
push: false
file: ${{ inputs.dockerfilePath }}/Dockerfile
tags: ${{ steps.dockerTags.outputs.tags }}

- name: Update Docker Hub description
if: steps.changes.outputs.apps == 'true'
uses: peter-evans/dockerhub-description@v4
with:
username: ${{ secrets.DOCKER_HUB_USER }}
Expand Down

0 comments on commit bf2838b

Please sign in to comment.