-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (57 loc) · 1.72 KB
/
ci.yaml
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
name: Java CI with Gradle
on:
push:
branches:
- main
- 'feature/**'
- 'bugfix/**'
pull_request:
branches:
- main
- 'feature/**'
- 'bugfix/**'
jobs:
tests:
name: Tests Runner
runs-on: ubuntu-latest
steps:
- name: Source Code Checkout
uses: actions/checkout@v2
- name: JDK Configure
uses: actions/setup-java@v2
with:
java-version: "17"
distribution: "temurin"
- name: Run application tests
run: ./gradlew test
build:
name: Build application
needs: tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0
- name: Build with Gradle Wrapper
run: ./gradlew clean build -x test
- name: Set build tag
run: echo "BUILD_TAG=$(echo ${{ github.head_ref || github.ref }} | sed 's,/,_,g')-${{ github.run_number }}" >> $GITHUB_ENV
- name: Print BUILD_TAG
run: echo "Branch ---> ${{ github.head_ref || github.ref }}" && echo "Tag ---> ${{ env.BUILD_TAG }}"
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: deyvisonborges
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push image
uses: docker/build-push-action@v2
with:
context: .
push: true
build-args: VERSION=${{ env.BUILD_TAG }}
tags: ${{ secrets.DOCKERHUB_USERNAME }}/your-image-name:${{ env.BUILD_TAG }}