Take Advantage Of Gradle Version Catalog #69
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Docker Image CI | |
on: | |
push: | |
branches: [ "master" ] | |
pull_request: | |
branches: [ "master" ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-java@v3 | |
with: | |
distribution: corretto | |
java-version: 21 | |
- name: Setup Gradle | |
uses: gradle/gradle-build-action@v2 | |
with: | |
gradle-version: 8.6 | |
- name: Cache SonarCloud packages | |
uses: actions/cache@v3 | |
with: | |
path: ~/.sonar/cache | |
key: ${{ runner.os }}-sonar | |
restore-keys: ${{ runner.os }}-sonar | |
- name: Cache Gradle packages | |
uses: actions/cache@v3 | |
with: | |
path: ~/.gradle/caches | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} | |
restore-keys: ${{ runner.os }}-gradle | |
- name: Build and analyze | |
env: | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
run: gradle build jacocoTestReport sonar --info | |
- name: Login to Docker Hub | |
run: docker login -u a002k -p ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build and tag the Docker image | |
run: | | |
COMMIT_SHA=$(echo $GITHUB_SHA | cut -c1-7) | |
docker build -t a002k/simple-app:$COMMIT_SHA -t a002k/simple-app:latest . | |
- name: Push the Docker image | |
run: docker push a002k/simple-app --all-tags |