-
Notifications
You must be signed in to change notification settings - Fork 0
74 lines (61 loc) · 2.08 KB
/
CI.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
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
69
70
71
72
73
74
name: Continuous Integration
on:
push:
branches-ignore:
- develop
- prod
env:
REGISTRY: ghcr.io
REPOSITORY: ${{ github.repository }}
IMAGE_TAG: ci:${{ github.ref_name }}-${{ github.sha }}
REGISTRY_USERNAME: ${{ github.actor }}
jobs:
Build:
name: Build & Delivery
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{secrets.TOKEN_GITHUB}}
submodules: true
- name: Setup Java JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
- name: Grant execute permission for gradlew
run: chmod +x ./gradlew
shell: bash
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- name: Build with Gradle
id: buildWithGradle
run: ./gradlew clean build -x test
shell: bash
- name: Upload Report Artifact When Build Failed
if: ${{ failure() && steps.buildWithGradle.conclusion == 'failure' }}
uses: actions/upload-artifact@v3
with:
name: report-artifact
path: ./build/reports
compression-level: 9
retention-days: 1
overwrite: true
- name: lowercase the image tag & repository
run: |
echo "REPOSITORY=$(echo $REPOSITORY | tr '[:upper:]' '[:lower:]')" >> ${GITHUB_ENV}
echo "IMAGE_TAG=$(echo $IMAGE_TAG | tr '[:upper:]' '[:lower:]')" >> ${GITHUB_ENV}
- name: Set Spring Image Environment Variable
run: |
echo "SPRING_IMAGE=${{ env.REGISTRY }}/${{ env.REPOSITORY }}-${{ env.IMAGE_TAG }}" >> ${GITHUB_ENV}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ env.REGISTRY_USERNAME }}
password: ${{ secrets.TOKEN_GITHUB }}
- name: Build Image
run: docker build --no-cache -t ${{ env.SPRING_IMAGE }} -f Dockerfile-CI .
- name: Push
run: docker push ${{ env.SPRING_IMAGE }}