Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhanced GH actions script to also tag built + pushed Docker images #693

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/maven.yml
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- master
- release-*

# Run build for any PR
pull_request:
Expand Down
52 changes: 35 additions & 17 deletions .github/workflows/push-dockerhub.yml
Expand Up @@ -17,35 +17,53 @@ jobs:
- name: Branch name
id: branch_name
run: |
echo ::set-output name=IMAGE_TAG::${GITHUB_REF#refs/tags/}
echo "::set-env name=IMAGE_TAG::${GITHUB_REF#refs/tags/}"
echo "::set-env name=IMAGE_MINOR_TAG::$(echo ${GITHUB_REF#refs/tags/} | cut -d. -f-2)"
echo "::set-env name=IMAGE_MAJOR_TAG::$(echo ${GITHUB_REF#refs/tags/} | cut -d. -f-1)"
echo "::set-env name=MILESTONE_OR_RC_SUFFIX::$(echo ${GITHUB_REF#refs/tags/} | cut -d- -f2)"
- name: Building Docker images for tag
run: |
echo $IMAGE_TAG
env:
IMAGE_TAG: ${{ steps.branch_name.outputs.IMAGE_TAG }}
echo $IMAGE_TAG
echo "Full version: $IMAGE_TAG"
echo "Minor version: $IMAGE_MINOR_TAG"
echo "Major version: $IMAGE_MAJOR_TAG"
echo "Milestone or RC suffix: $MILESTONE_OR_RC_SUFFIX"
- name: Build the Docker images
run: |
docker build -f services/dockerfile-release --build-arg SERVICE_STARTER=ditto-services-policies-starter --build-arg SERVICE_VERSION=$IMAGE_TAG -t eclipse/ditto-policies:$IMAGE_TAG -t eclipse/ditto-policies:latest .;
docker build -f services/dockerfile-release --build-arg SERVICE_STARTER=ditto-services-things-starter --build-arg SERVICE_VERSION=$IMAGE_TAG -t eclipse/ditto-things:$IMAGE_TAG -t eclipse/ditto-things:latest .;
docker build -f services/dockerfile-release --build-arg SERVICE_STARTER=ditto-services-thingsearch-starter --build-arg SERVICE_VERSION=$IMAGE_TAG -t eclipse/ditto-things-search:$IMAGE_TAG -t eclipse/ditto-things-search:latest .;
docker build -f services/dockerfile-release --build-arg SERVICE_STARTER=ditto-services-concierge-starter --build-arg SERVICE_VERSION=$IMAGE_TAG -t eclipse/ditto-concierge:$IMAGE_TAG -t eclipse/ditto-concierge:latest .;
docker build -f services/dockerfile-release --build-arg SERVICE_STARTER=ditto-services-gateway-starter --build-arg SERVICE_VERSION=$IMAGE_TAG -t eclipse/ditto-gateway:$IMAGE_TAG -t eclipse/ditto-gateway:latest .;
docker build -f services/dockerfile-release --build-arg SERVICE_STARTER=ditto-services-connectivity-starter --build-arg SERVICE_VERSION=$IMAGE_TAG -t eclipse/ditto-connectivity:$IMAGE_TAG -t eclipse/ditto-connectivity:latest .;
docker build -f services/dockerfile-release --build-arg SERVICE_STARTER=ditto-services-policies-starter --build-arg SERVICE_VERSION=$IMAGE_TAG -t eclipse/ditto-policies:$IMAGE_TAG -t eclipse/ditto-policies:$IMAGE_MINOR_TAG -t eclipse/ditto-policies:$IMAGE_MAJOR_TAG -t eclipse/ditto-policies:latest .;
docker build -f services/dockerfile-release --build-arg SERVICE_STARTER=ditto-services-things-starter --build-arg SERVICE_VERSION=$IMAGE_TAG -t eclipse/ditto-things:$IMAGE_TAG -t eclipse/ditto-things:$IMAGE_MINOR_TAG -t eclipse/ditto-things:$IMAGE_MAJOR_TAG -t eclipse/ditto-things:latest .;
docker build -f services/dockerfile-release --build-arg SERVICE_STARTER=ditto-services-thingsearch-starter --build-arg SERVICE_VERSION=$IMAGE_TAG -t eclipse/ditto-things-search:$IMAGE_TAG -t eclipse/ditto-things-search:$IMAGE_MINOR_TAG -t eclipse/ditto-things-search:$IMAGE_MAJOR_TAG -t eclipse/ditto-things-search:latest .;
docker build -f services/dockerfile-release --build-arg SERVICE_STARTER=ditto-services-concierge-starter --build-arg SERVICE_VERSION=$IMAGE_TAG -t eclipse/ditto-concierge:$IMAGE_TAG -t eclipse/ditto-concierge:$IMAGE_MINOR_TAG -t eclipse/ditto-concierge:$IMAGE_MAJOR_TAG -t eclipse/ditto-concierge:latest .;
docker build -f services/dockerfile-release --build-arg SERVICE_STARTER=ditto-services-gateway-starter --build-arg SERVICE_VERSION=$IMAGE_TAG -t eclipse/ditto-gateway:$IMAGE_TAG -t eclipse/ditto-gateway:$IMAGE_MINOR_TAG -t eclipse/ditto-gateway:$IMAGE_MAJOR_TAG -t eclipse/ditto-gateway:latest .;
docker build -f services/dockerfile-release --build-arg SERVICE_STARTER=ditto-services-connectivity-starter --build-arg SERVICE_VERSION=$IMAGE_TAG -t eclipse/ditto-connectivity:$IMAGE_TAG -t eclipse/ditto-connectivity:$IMAGE_MINOR_TAG -t eclipse/ditto-connectivity:$IMAGE_MAJOR_TAG -t eclipse/ditto-connectivity:latest .;
env:
IMAGE_TAG: ${{ steps.branch_name.outputs.IMAGE_TAG }}
- name: Push the Docker images to Docker Hub
run: |
docker push eclipse/ditto-policies:$IMAGE_TAG;
docker push eclipse/ditto-policies:latest;
docker push eclipse/ditto-things:$IMAGE_TAG;
docker push eclipse/ditto-things:latest;
docker push eclipse/ditto-things-search:$IMAGE_TAG;
docker push eclipse/ditto-things-search:latest;
docker push eclipse/ditto-concierge:$IMAGE_TAG;
docker push eclipse/ditto-concierge:latest;
docker push eclipse/ditto-gateway:$IMAGE_TAG;
docker push eclipse/ditto-gateway:latest;
docker push eclipse/ditto-connectivity:$IMAGE_TAG;
- name: Push the Docker images of tag aliases to Docker Hub
if: env.MILESTONE_OR_RC_SUFFIX == env.IMAGE_TAG
run: |
docker push eclipse/ditto-policies:$IMAGE_MINOR_TAG;
docker push eclipse/ditto-policies:$IMAGE_MAJOR_TAG;
docker push eclipse/ditto-policies:latest;
docker push eclipse/ditto-things:$IMAGE_MINOR_TAG;
docker push eclipse/ditto-things:$IMAGE_MAJOR_TAG;
docker push eclipse/ditto-things:latest;
docker push eclipse/ditto-things-search:$IMAGE_MINOR_TAG;
docker push eclipse/ditto-things-search:$IMAGE_MAJOR_TAG;
docker push eclipse/ditto-things-search:latest;
docker push eclipse/ditto-concierge:$IMAGE_MINOR_TAG;
docker push eclipse/ditto-concierge:$IMAGE_MAJOR_TAG;
docker push eclipse/ditto-concierge:latest;
docker push eclipse/ditto-gateway:$IMAGE_MINOR_TAG;
docker push eclipse/ditto-gateway:$IMAGE_MAJOR_TAG;
docker push eclipse/ditto-gateway:latest;
docker push eclipse/ditto-connectivity:$IMAGE_MINOR_TAG;
docker push eclipse/ditto-connectivity:$IMAGE_MAJOR_TAG;
docker push eclipse/ditto-connectivity:latest;
env:
IMAGE_TAG: ${{ steps.branch_name.outputs.IMAGE_TAG }}