Created
November 23, 2020 15:52
-
-
Save mihkels/f19ea45e4d05b7741569d7575f5f7026 to your computer and use it in GitHub Desktop.
Build Spring Boot with Gradle and push docker image to Github Docker registry
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: build | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
jobs: | |
gradle: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v1 | |
- uses: actions/setup-java@v1 | |
with: | |
java-version: 14 | |
- uses: eskatos/[email protected] | |
with: | |
arguments: build | |
wrapper-cache-enabled: true | |
dependencies-cache-enabled: true | |
configuration-cache-enabled: true | |
- name: Upload build JAR | |
uses: actions/upload-artifact@v2 | |
with: | |
name: build | |
path: build | |
docker: | |
runs-on: ubuntu-latest | |
needs: gradle | |
steps: | |
- name: Checkout the code | |
uses: actions/checkout@v1 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v1 | |
- name: Set up Docker Build | |
uses: docker/setup-buildx-action@v1 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.CR_PAT }} | |
- name: Download gradle build result | |
uses: actions/download-artifact@v2 | |
with: | |
name: build | |
path: build | |
- run: pwd . | |
- run: ls build | |
- name: Build and push | |
id: docker_build | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
push: true | |
tags: ghcr.io/mihkels/actions-demo:latest | |
build-args: | | |
BUILD_DATA_DIR=build/libs | |
- name: Image digest | |
run: echo ${{ steps.docker_build.outputs.digest }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment