-
Notifications
You must be signed in to change notification settings - Fork 0
39 lines (30 loc) · 1.12 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
name: Build
on:
push:
branches: [master]
pull_request:
branches: [master]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: "11"
distribution: "adopt"
- name: Build for push
run: mvn -B clean package -Dskip.docker.build=true
- name: Login to Docker Hub
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v3.x
- name: Building and publich Docker Image
run: |
IMAGE_NAME=${{ secrets.DOCKER_USERNAME }}/${{ secrets.APP_NAME }}
TAG=`if [ "${{ env.GITHUB_REF_SLUG }}" == "master" ]; then echo "latest"; else echo ${{ env.GITHUB_REF_SLUG }}; fi`
docker build -t $IMAGE_NAME:${{ env.GITHUB_SHA_SHORT }} -t $IMAGE_NAME:$TAG --build-arg JAR_FILE=target/${{ secrets.APP_NAME }}.jar .
docker push $IMAGE_NAME --all-tags