Skip to content

Commit 80ba959

Browse files
committed
Merge branch 'main' of https://github.com/kafbat/kafka-ui into issues/117-reusable-workflow
2 parents 8e0c4db + 91ed167 commit 80ba959

File tree

2 files changed

+130
-1
lines changed

2 files changed

+130
-1
lines changed
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: "Docker publish"
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
version:
7+
required: true
8+
type: string
9+
generic_tag:
10+
required: true
11+
type: string
12+
13+
permissions:
14+
packages: write
15+
id-token: write # Required to authenticate with OIDC for AWS
16+
17+
jobs:
18+
deploy:
19+
continue-on-error: true
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
registry: [ 'docker.io', 'ghcr.io', 'ecr' ]
24+
25+
runs-on: ubuntu-latest
26+
steps:
27+
28+
- name: Download docker image
29+
uses: actions/download-artifact@v4
30+
with:
31+
name: image
32+
path: /tmp
33+
34+
# setup containerd to preserve provenance attestations :https://docs.docker.com/build/attestations/#creating-attestations
35+
- name: Setup docker with containerd
36+
uses: crazy-max/ghaction-setup-docker@v3
37+
with:
38+
daemon-config: |
39+
{
40+
"features": {
41+
"containerd-snapshotter": true
42+
}
43+
}
44+
45+
- name: Load docker image into daemon
46+
run: |
47+
docker load --input /tmp/image.tar
48+
49+
- name: Login to docker.io
50+
if: matrix.registry == 'docker.io'
51+
uses: docker/login-action@v3
52+
with:
53+
registry: ${{ matrix.registry }}
54+
username: ${{ secrets.DOCKERHUB_USERNAME }}
55+
password: ${{ secrets.DOCKERHUB_TOKEN }}
56+
57+
- name: Login to ghcr.io
58+
if: matrix.registry == 'ghcr.io'
59+
uses: docker/login-action@v3
60+
with:
61+
registry: ${{ matrix.registry }}
62+
username: ${{ github.actor }}
63+
password: ${{ secrets.GITHUB_TOKEN }}
64+
65+
- name: Configure AWS credentials
66+
if: matrix.registry == 'ecr'
67+
uses: aws-actions/configure-aws-credentials@v4
68+
with:
69+
aws-region: us-east-1 # This region only for public ECR
70+
role-to-assume: ${{ secrets.AWS_ROLE }}
71+
72+
- name: Login to public ECR
73+
if: matrix.registry == 'ecr'
74+
id: login-ecr-public
75+
uses: aws-actions/amazon-ecr-login@v2
76+
with:
77+
registry-type: public
78+
79+
- name: define env vars
80+
run: |
81+
if [ ${{matrix.registry }} == 'docker.io' ]; then
82+
echo "REGISTRY=${{ matrix.registry }}" >> $GITHUB_ENV
83+
echo "REPOSITORY=${{ github.repository }}" >> $GITHUB_ENV
84+
elif [ ${{ matrix.registry }} == 'ghcr.io' ]; then
85+
echo "REGISTRY=${{ matrix.registry }}" >> $GITHUB_ENV
86+
echo "REPOSITORY=${{ github.repository }}" >> $GITHUB_ENV
87+
elif [ ${{ matrix.registry }} == 'ecr' ]; then
88+
echo "REGISTRY=${{ vars.ECR_REGISTRY }}" >> $GITHUB_ENV
89+
echo "REPOSITORY=${{ github.repository }}" >> $GITHUB_ENV
90+
else
91+
echo "REGISTRY=" >> $GITHUB_ENV
92+
echo "REPOSITORY=notworking" >> $GITHUB_ENV
93+
fi
94+
95+
- name: Push images to ${{ matrix.registry }}
96+
run: |
97+
docker tag kafka-ui:temp ${{ env.REGISTRY }}/${{ env.REPOSITORY }}:${{ inputs.generic_tag }}
98+
docker tag kafka-ui:temp ${{ env.REGISTRY }}/${{ env.REPOSITORY }}:${{ inputs.version }}
99+
docker push ${{ env.REGISTRY }}/${{ env.REPOSITORY }}:${{ inputs.generic_tag }}
100+
docker push ${{ env.REGISTRY }}/${{ env.REPOSITORY }}:${{ inputs.version }}

.github/workflows/main.yml

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ permissions:
99
contents: read
1010

1111
jobs:
12-
jar-build:
12+
jar-jar-build:
1313
runs-on: ubuntu-latest
1414

1515
permissions:
@@ -18,6 +18,9 @@ jobs:
1818
outputs:
1919
version: ${{steps.build.outputs.version}}
2020

21+
outputs:
22+
version: ${{steps.build.outputs.version}}
23+
2124
steps:
2225
- name: Checkout
2326
uses: actions/checkout@v4
@@ -40,6 +43,8 @@ jobs:
4043
export VERSION=$(./mvnw -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
4144
echo "version=${VERSION}" >> $GITHUB_OUTPUT
4245
46+
- name: Upload jar
47+
uses: actions/upload-artifact@v4
4348
- name: Upload jar
4449
uses: actions/upload-artifact@v4
4550
with:
@@ -57,6 +62,30 @@ jobs:
5762
sha: ${{ github.sha }}
5863
version: ${{ needs.jar-build.outputs.version }}
5964

65+
docker-deploy:
66+
needs: [ jar-build, docker-build ]
67+
permissions:
68+
packages: write
69+
id-token: write # Required to authenticate with OIDC for AWS
70+
uses: ./.github/workflows/docker_publish.yml
71+
secrets: inherit
72+
with:
73+
version: ${{ needs.jar-build.outputs.version }}
74+
generic_tag: main
75+
name: kafbat-ui-${{ steps.build.outputs.version }}
76+
path: api/target/api-${{ steps.build.outputs.version }}.jar
77+
retention-days: 1
78+
79+
docker-build:
80+
needs: jar-build
81+
permissions:
82+
contents: read
83+
uses: ./.github/workflows/docker_build.yml
84+
secrets: inherit
85+
with:
86+
sha: ${{ github.sha }}
87+
version: ${{ needs.jar-build.outputs.version }}
88+
6089
docker-deploy:
6190
needs: [ jar-build, docker-build ]
6291
permissions:

0 commit comments

Comments
 (0)