-
Notifications
You must be signed in to change notification settings - Fork 5
126 lines (118 loc) · 3.72 KB
/
gradlebuild.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
name: Build
on:
push:
# Publish `master` as Docker `latest` image.
branches:
- main
# Publish `v1.2.3` tags as releases.
tags:
- v*
# Run tests for any PRs.
pull_request:
env:
GITHUB_WORKFLOW: dati-semantic-backend
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'
- name: checkout code
uses: actions/checkout@v2
- name: caching
uses: actions/cache@v1
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Create Build Artifact
run: ./gradlew clean build
- name: SpotBugs Check
run: ./gradlew spotbugsMain spotbugsTest
owasp:
runs-on: ubuntu-latest
steps:
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'
- name: checkout code
uses: actions/checkout@v2
- name: Dependency Check
run: ./gradlew dependencyCheckAnalyze
publish:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
permissions:
contents: read
packages: write
needs:
- build
- owasp
steps:
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'
- name: Checkout repository
uses: actions/checkout@v2
- name: Log in to the Github Container registry
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: caching
uses: actions/cache@v1
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: build and push image
run: |
IMAGE="$REGISTRY/$IMAGE_NAME"
TAG="$(date +'%Y%m%d')-${{github.run_number}}-$(git rev-parse --short HEAD)"
SOURCE_LABEL="org.opencontainers.image.source=${{github.server_url}}/$IMAGE_NAME"
BRANCH_LABEL="org.opencontainers.image.source.branch=$(git rev-parse --abbrev-ref HEAD)"
TITLE_LABEL="org.opencontainers.image.title=dati-semantic-backend"
./gradlew jib --image="$IMAGE:$TAG" -Djib.container.labels="$SOURCE_LABEL,$BRANCH_LABEL,$TITLE_LABEL" -Djib.to.tags="$TAG,latest"
deploy:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
permissions:
contents: read
packages: write
needs:
- publish
steps:
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'
- name: Checkout repository
uses: actions/checkout@v2
- name: extract image
id: extractImage
run: |
IMAGE="$REGISTRY/$IMAGE_NAME"
TAG="$(date +'%Y%m%d')-${{github.run_number}}-$(git rev-parse --short HEAD)"
echo "##[set-output name=imageName;]${IMAGE}:${TAG}"
- uses: convictional/[email protected]
with:
owner: teamdigitale
repo: dati-semantic-kubernetes
github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
workflow_file_name: update-config.yaml
ref: dev
wait_interval: 20
inputs: '{"serviceName": "dati-semantic-backend", "imageWithNewTag": "${{ steps.extractImage.outputs.imageName }}"}'