Skip to content

Bump io.spring.dependency-management from 1.1.6 to 1.1.7 (#58) #147

Bump io.spring.dependency-management from 1.1.6 to 1.1.7 (#58)

Bump io.spring.dependency-management from 1.1.6 to 1.1.7 (#58) #147

name: Docker
on:
push:
branches:
- main
tags:
- v*
pull_request:
branches: [ main ]
env:
IMAGE_NAME: springboilerplate
jobs:
test:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'zulu'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build
- name: Test
run: ./gradlew test
- uses: codecov/codecov-action@v5
- name: Build image
run: ./gradlew bootBuildImage --imageName=$IMAGE_NAME
push:
needs: test
runs-on: ubuntu-22.04
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'zulu'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build image
run: ./gradlew bootBuildImage --imageName=$IMAGE_NAME
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push image
run: |
IMAGE_ID_GITHUB=ghcr.io/${{ github.repository }}
IMAGE_ID_HUB=bervproject/$IMAGE_NAME
# Change all uppercase to lowercase
IMAGE_ID_GITHUB=$(echo $IMAGE_ID_GITHUB | tr '[A-Z]' '[a-z]')
IMAGE_ID_HUB=$(echo $IMAGE_ID_HUB | tr '[A-Z]' '[a-z]')
# Strip git ref prefix from version
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" ] && VERSION=latest
docker tag $IMAGE_NAME $IMAGE_ID_GITHUB:$VERSION
docker tag $IMAGE_NAME $IMAGE_ID_HUB:$VERSION
docker push $IMAGE_ID_GITHUB:$VERSION
docker push $IMAGE_ID_HUB:$VERSION