-
-
Notifications
You must be signed in to change notification settings - Fork 356
110 lines (108 loc) · 4.4 KB
/
build-on-push.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
name: build
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
postgresql: ['10', '15','16']
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: |
${{ runner.os }}-gradle-
- uses: actions/cache@v3
with:
path: ~/.gradle/wrapper
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradlew') }}
restore-keys: |
${{ runner.os }}-gradlew-
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
- name: Build with Gradle
run: ./gradlew build distribution jacocoTestReport -Dpgsql.version=${{ matrix.postgresql }}
- name: upload to sonarcloud
if: ${{ github.repository == 'alfio-event/alf.io' && matrix.postgresql == '16'}}
run: ./gradlew sonarqube
env:
SONARCLOUD_TOKEN: ${{ secrets.SONAR_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: 'Upload Build'
if: ${{ github.repository == 'alfio-event/alf.io' && matrix.postgresql == '10'}}
uses: actions/upload-artifact@v4
with:
name: dist
path: build
retention-days: 5
push_image_dev:
runs-on: ubuntu-latest
if: ${{ github.repository == 'alfio-event/alf.io' && github.event_name == 'push' }}
needs: build
name: Push dev image
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: dist
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Configure Docker
uses: docker/setup-buildx-action@v2
- name: Login to Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ secrets.CR_USER }}
password: ${{ secrets.CR_PAT }}
- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v4
- name: Push Docker image
uses: docker/build-push-action@v4
with:
context: ./dockerize
tags: |
ghcr.io/alfio-event/alf.io/dev-${{ env.GITHUB_REF_SLUG }}:latest
platforms: linux/amd64,linux/arm64
push: true
push_image_prod:
runs-on: ubuntu-latest
if: ${{ github.repository == 'alfio-event/alf.io' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }}
needs: build
name: Push PROD image
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: dist
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Configure Docker
uses: docker/setup-buildx-action@v2
- name: Login to Container Registry (GitHub)
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ secrets.CR_USER }}
password: ${{ secrets.CR_PAT }}
- name: Login to Container Registry (Docker)
uses: docker/login-action@v2
with:
registry: docker.io
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push Docker image
uses: docker/build-push-action@v4
with:
context: ./dockerize
tags: |
ghcr.io/alfio-event/alf.io/prod:${{github.ref_name}}
alfio/alf.io:${{github.ref_name}}
alfio/alf.io:latest
platforms: linux/amd64,linux/arm64
push: true