Skip to content

Commit 5b83013

Browse files
committed
updated for main branch
1 parent 9a5ff39 commit 5b83013

File tree

7 files changed

+139
-99
lines changed

7 files changed

+139
-99
lines changed

.github/workflows/branch-deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
echo "version=${VERSION}" >> $GITHUB_OUTPUT
4242
4343
- name: Build and Push Docker Image
44-
uses: ./.github/workflows/build-docker
44+
uses: ./.github/workflows/docker_build
4545
with:
4646
tag: ${{ steps.extract_branch.outputs.tag }}
4747
version: ${{ steps.build.outputs.version }}

.github/workflows/build-docker.yml

Lines changed: 0 additions & 61 deletions
This file was deleted.

.github/workflows/build-public-image.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
echo "version=${VERSION}" >> $GITHUB_OUTPUT
4141
4242
- name: Build and Test Docker Image
43-
uses: ./.github/workflows/build-docker
43+
uses: ./.github/workflows/docker_build
4444
with:
4545
tag: ${{ steps.extract_branch.outputs.tag }}
4646
version: ${{ steps.build.outputs.version }}

.github/workflows/cve_checks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
echo "version=${VERSION}" >> $GITHUB_OUTPUT
4141
4242
- name: Build Docker Image
43-
uses: ./.github/workflows/build-docker
43+
uses: ./.github/workflows/docker_build
4444
with:
4545
tag: ${{ steps.extract_branch.outputs.tag }}
4646
version: ${{ steps.build.outputs.version }}

.github/workflows/docker_build.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: "Docker build"
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
sha:
7+
required: true
8+
type: string
9+
version:
10+
required: true
11+
type: string
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
build:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
with:
23+
ref: ${{ inputs.sha }}
24+
token: ${{ github.token }}
25+
26+
- name: Download maven artifacts
27+
uses: actions/download-artifact@v4
28+
with:
29+
name: kafbat-ui-${{ inputs.version }}
30+
path: api/target
31+
32+
- name: Set up QEMU
33+
uses: docker/setup-qemu-action@v3
34+
35+
- name: Set up Docker Buildx
36+
id: buildx
37+
uses: docker/setup-buildx-action@v3
38+
39+
- name: Cache Docker layers
40+
uses: actions/cache@v4
41+
with:
42+
path: /tmp/.buildx-cache
43+
key: ${{ runner.os }}-buildx-${{ inputs.sha }}
44+
restore-keys: |
45+
${{ runner.os }}-buildx-
46+
47+
- name: Setup docker with containerd
48+
uses: crazy-max/ghaction-setup-docker@v3
49+
with:
50+
daemon-config: |
51+
{
52+
"features": {
53+
"containerd-snapshotter": true
54+
}
55+
}
56+
57+
- name: Build docker image
58+
id: docker_build
59+
uses: docker/build-push-action@v5
60+
with:
61+
builder: ${{ steps.buildx.outputs.name }}
62+
context: api
63+
platforms: linux/amd64,linux/arm64
64+
provenance: mode=min
65+
sbom: true
66+
push: false
67+
load: true
68+
tags: |
69+
kafka-ui:temp
70+
build-args: |
71+
JAR_FILE=api-${{ inputs.version }}.jar
72+
cache-from: type=local,src=/tmp/.buildx-cache
73+
cache-to: type=local,dest=/tmp/.buildx-cache
74+
75+
- name: Dump docker image
76+
run: |
77+
docker image save kafka-ui:temp > /tmp/image.tar
78+
79+
- name: Upload docker image
80+
uses: actions/upload-artifact@v4
81+
with:
82+
name: image
83+
path: /tmp/image.tar
84+
retention-days: 1

.github/workflows/main.yml

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,20 @@ permissions:
99
contents: read
1010

1111
jobs:
12-
build:
12+
jar-build:
1313
runs-on: ubuntu-latest
14+
1415
permissions:
1516
contents: read
16-
packages: write
17+
18+
outputs:
19+
version: ${{steps.build.outputs.version}}
1720

1821
steps:
1922
- name: Checkout
2023
uses: actions/checkout@v4
2124
with:
22-
ref: ${{ github.event.pull_request.head.sha }}
25+
ref: ${{ github.sha }} # Используем входной параметр sha
2326
token: ${{ github.token }}
2427

2528
- name: Set up JDK
@@ -37,25 +40,30 @@ jobs:
3740
export VERSION=$(./mvnw -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
3841
echo "version=${VERSION}" >> $GITHUB_OUTPUT
3942
40-
- name: Build & Push Docker Image
41-
uses: ./.github/workflows/build-docker
43+
- name: Upload jar
44+
uses: actions/upload-artifact@v4
4245
with:
43-
tag: ${{ steps.build.outputs.version }}
44-
version: ${{ steps.build.outputs.version }}
45-
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
46-
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
47-
aws-region: eu-central-1
48-
repository: ghcr.io/kafbat/kafka-ui
49-
build-context: api
50-
51-
- name: Login to GitHub Container Registry
52-
uses: docker/login-action@v3
53-
with:
54-
registry: ghcr.io
55-
username: ${{ github.actor }}
56-
password: ${{ secrets.GITHUB_TOKEN }}
46+
name: kafbat-ui-${{ steps.build.outputs.version }}
47+
path: api/target/api-${{ steps.build.outputs.version }}.jar
48+
retention-days: 1
5749

58-
- name: Push additional tag for main branch
59-
run: |
60-
docker tag ghcr.io/kafbat/kafka-ui:${{ steps.build.outputs.version }} ghcr.io/kafbat/kafka-ui:main
61-
docker push ghcr.io/kafbat/kafka-ui:main
50+
docker-build:
51+
needs: jar-build
52+
permissions:
53+
contents: read
54+
uses: ./.github/workflows/docker_build.yml
55+
secrets: inherit
56+
with:
57+
sha: ${{ github.sha }}
58+
version: ${{ needs.jar-build.outputs.version }}
59+
60+
docker-deploy:
61+
needs: [ jar-build, docker-build ]
62+
permissions:
63+
packages: write
64+
id-token: write
65+
uses: ./.github/workflows/docker_publish.yml
66+
secrets: inherit
67+
with:
68+
version: ${{ needs.jar-build.outputs.version }}
69+
generic_tag: main

.github/workflows/release.yml

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- uses: actions/checkout@v4
2020
with:
2121
fetch-depth: 0
22-
ref: ${{ github.event.pull_request.head.sha }}
22+
ref: ${{ github.sha }}
2323
token: ${{ github.token }}
2424

2525
- run: |
@@ -54,17 +54,26 @@ jobs:
5454
name: kafbat-ui-${{ steps.build.outputs.version }}
5555
path: api/target/api-${{ steps.build.outputs.version }}.jar
5656

57-
# Docker images
58-
- name: Build & Push Docker Image
59-
uses: ./.github/workflows/build-docker
60-
with:
61-
tag: ${{ steps.build.outputs.version }}
62-
version: ${{ steps.build.outputs.version }}
63-
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
64-
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
65-
aws-region: eu-central-1
66-
repository: ghcr.io/kafbat/kafka-ui
67-
build-context: api
57+
docker-build:
58+
needs: release
59+
permissions:
60+
contents: read
61+
uses: ./.github/workflows/docker_build.yml
62+
secrets: inherit
63+
with:
64+
sha: ${{ github.sha }}
65+
version: ${{ needs.release.outputs.version }}
66+
67+
docker-deploy:
68+
needs: [release, docker-build]
69+
permissions:
70+
packages: write
71+
id-token: write
72+
uses: ./.github/workflows/docker_publish.yml
73+
secrets: inherit
74+
with:
75+
version: ${{ needs.release.outputs.version }}
76+
generic_tag: latest
6877

6978
charts:
7079
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)