-
Notifications
You must be signed in to change notification settings - Fork 0
129 lines (124 loc) · 4.6 KB
/
gradle-build.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
127
128
129
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle
name: Gradle Build Image
run-name: ${{ github.actor }} is Build Boot Image Actions
on:
push:
branches:
- 'main'
- 'dev'
tags:
- 'v*'
release:
types: [ created ]
env:
GITHUB_REGISTRY: ghcr.io/${{ github.actor }}
DOCKER_REGISTRY: docker.io/alexbob
tags: |
type=semver,pattern={{version}},value=v0.0.4
type=semver,pattern={{major}}.{{minor}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }}
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }}
type=ref,event=tag
jobs:
boot-build-image:
runs-on: ubuntu-latest
services:
registry:
image: registry:2
ports:
- 5000:5000
permissions:
contents: read
packages: write
env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: '5'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: gradle/actions/wrapper-validation@v4
- name: Set up java 21 for x64
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'liberica'
cache: 'gradle'
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: linux/amd64,linux/arm64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: network=host
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Execute Gradle Plate bootBuildImage
run: |
chmod +x ./gradlew
./gradlew bootBuildImage --imagePlatform=linux/amd64 --network=host --publishImage --scan
./gradlew bootBuildImage --imagePlatform=linux/arm64 --network=host --publishImage --scan
- name: Inspect
run: |
docker buildx imagetools inspect localhost:5000/plate-oauth2:latest
docker buildx imagetools inspect localhost:5000/plate-platform:latest
- name: Log into registry ${{ env.GITHUB_REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.GITHUB_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.PAGK_TOKEN }}
- name: Log into registry ${{ env.DOCKER_REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Extract platform metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
flavor: |
latest=true
images: |
${{ env.GITHUB_REGISTRY }}/plate-platform
${{ env.DOCKER_REGISTRY }}/plate-platform
tags: ${{ env.tags }}
- name: Build and Push Platform
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
context: ./boot/platform
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Upload Platform Image to Registry
run: |
echo "Upload images ${{ steps.meta.outputs.tags }} to registry."
echo "Upload labels ${{ steps.meta.outputs.labels }} to registry"
- name: Extract oauth2 metadata (tags, labels) for Docker
id: oauth2
uses: docker/metadata-action@v5
with:
flavor: |
latest=true
images: |
${{ env.GITHUB_REGISTRY }}/plate-oauth2
${{ env.DOCKER_REGISTRY }}/plate-oauth2
tags: ${{ env.tags }}
- name: Build and Push Oauth2
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
context: ./boot/oauth2
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.oauth2.outputs.tags }}
labels: ${{ steps.oauth2.outputs.labels }}
- name: Upload Oauth2 Image to Registry
run: |
echo "Upload images ${{ steps.oauth2.outputs.tags }} to registry."
echo "Upload labels ${{ steps.oauth2.outputs.labels }} to registry"