forked from innopolis-devops/labs
-
Notifications
You must be signed in to change notification settings - Fork 0
94 lines (78 loc) · 2.42 KB
/
kotlin_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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: Kotlin CI
on: [ push, pull_request ]
jobs:
changes:
timeout-minutes: 10
runs-on: ubuntu-latest
outputs:
app_kotlin: ${{ steps.filter.outputs.app_kotlin }}
steps:
- uses: actions/checkout@v2
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
app_kotlin:
- 'app_kotlin/**'
build:
if: ${{ needs.changes.outputs.app_kotlin == 'true' }}
needs: [ changes ]
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-version: 7.5
- name: Execute Gradle build
run: |
cd app_kotlin
gradle build
security:
if: ${{ needs.changes.outputs.app_kotlin == 'true' }}
needs: [ build ]
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: snyk/actions/setup@master
- name: Run Snyk to check for vulnerabilities
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
continue-on-error: true
run: |
cd app_kotlin
snyk test --all-projects --sarif-file-output=result.sarif
- name: Upload result to GitHub Code Scanning
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: app_kotlin/result.sarif
publish-image:
if: ${{ needs.changes.outputs.app_kotlin == 'true' }}
needs: [ security ]
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build and push
uses: docker/build-push-action@v2
with:
context: app_kotlin
push: true
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/app_kotlin:latest
cache-from: type=registry,ref=${{ secrets.DOCKER_HUB_USERNAME }}/app_kotlin:buildcache
cache-to: type=registry,ref=${{ secrets.DOCKER_HUB_USERNAME }}/app_kotlin:buildcache,mode=max