From a699d636d70f0bf45c4ad3e96680052b45d893d0 Mon Sep 17 00:00:00 2001 From: kasramp Date: Wed, 3 May 2023 10:01:39 +0200 Subject: [PATCH] #25 build Docker images and push them to Docker Hub when running master pipeline --- .github/workflows/build_and_release.yml | 2 ++ util/release.sh | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_and_release.yml b/.github/workflows/build_and_release.yml index 8c13349..657f49f 100644 --- a/.github/workflows/build_and_release.yml +++ b/.github/workflows/build_and_release.yml @@ -49,6 +49,8 @@ jobs: EMAIL: ${{ secrets.EMAIL }} USERNAME: ${{ secrets.USERNAME }} TOKEN: ${{ secrets.GITHUB_TOKEN }} + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} run: | pwd ${GITHUB_WORKSPACE} chmod +x "${GITHUB_WORKSPACE}/util/release.sh" diff --git a/util/release.sh b/util/release.sh index b8a6668..e1dc0e1 100755 --- a/util/release.sh +++ b/util/release.sh @@ -10,9 +10,14 @@ if [[ "$LAST_COMMIT" != *"maven-release-plugin"* ]]; then mvn -B clean release:clean release:prepare release:perform -Dusername=$USERNAME -Dpassword=$TOKEN -DtagNameFormat=@{artifactId}-beta-@{version} -Darguments="-Dmaven.deploy.skip=true" else mvn -B clean release:clean release:prepare release:perform -Dusername=$USERNAME -Dpassword=$TOKEN -Darguments="-Dmaven.deploy.skip=true" && - mvn clean spring-boot:build-image && TAGGED_VERSION=$(git for-each-ref --sort=-creatordate --format='%(refname:short)' refs/tags --count 10 | grep -oP '^eris-(\d+).*' | head -1 | cut -d "-" -f2) && - docker tag eris:"$TAGGED_VERSION" eris:latest && + IMAGE_NAME=kasramp/eris && + mvn versions:set -DnewVersion="$TAGGED_VERSION" && + mvn spring-boot:build-image -Dspring-boot.build-image.imageName="$IMAGE_NAME":"$TAGGED_VERSION" && + docker tag "$IMAGE_NAME":"$TAGGED_VERSION" "$IMAGE_NAME":latest && + docker login -u "$DOCKER_USERNAME" --password-stdin <<< "$DOCKER_PASSWORD" && + docker push "$IMAGE_NAME" --all-tags && + git checkout pom.xml && git fetch origin develop && git merge origin/master && git push https://$USERNAME:$TOKEN@github.com/kasramp/Eris.git HEAD:develop fi