Skip to content

Commit eae5f55

Browse files
committed
Switch to matrix workflow
1 parent 76ed720 commit eae5f55

File tree

2 files changed

+83
-25
lines changed

2 files changed

+83
-25
lines changed

.github/workflows/docker_publish.yml

Lines changed: 82 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,89 @@ on:
99
type: string
1010
generic_tag:
1111
required: true
12-
type: string
12+
type: string
1313

1414
jobs:
15-
deploy-ghcr:
16-
permissions:
17-
packages: write
18-
uses: ./.github/workflows/publish_ghcr.yml
19-
secrets: inherit
20-
with:
21-
version: ${{ inputs.version }}
22-
generic_tag: ${{ inputs.generic_tag }}
15+
deploy:
16+
continue-on-error: true
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
registry: ['docker.io', 'ghcr.io', 'ecr']
21+
22+
runs-on: ubuntu-latest
23+
steps:
24+
25+
- name: Download docker image
26+
uses: actions/download-artifact@v4
27+
with:
28+
name: image
29+
path: /tmp
30+
31+
# setup containerd to preserve provenance attestations :https://docs.docker.com/build/attestations/#creating-attestations
32+
- name: Setup docker with containerd
33+
uses: crazy-max/ghaction-setup-docker@v3
34+
with:
35+
daemon-config: |
36+
{
37+
"features": {
38+
"containerd-snapshotter": true
39+
}
40+
}
41+
42+
- name: Load docker image into daemon
43+
run: |
44+
docker load --input /tmp/image.tar
2345
24-
deploy-dockerhub:
25-
uses: ./.github/workflows/publish_dockerhub.yml
26-
secrets: inherit
27-
with:
28-
version: ${{ inputs.version }}
29-
generic_tag: ${{ inputs.generic_tag }}
46+
- name: Login to docker.io
47+
if: matrix.registry == 'docker.io'
48+
uses: docker/login-action@v3
49+
with:
50+
registry: ${{ matrix.registry }}
51+
username: ${{ secrets.DOCKERHUB_USERNAME }}
52+
password: ${{ secrets.DOCKERHUB_TOKEN }}
3053

31-
deploy-ecr:
32-
uses: ./.github/workflows/publish_ecr.yml
33-
permissions:
34-
contents: read # To read secrets
35-
id-token: write # This is required for requesting the JWT
36-
secrets: inherit
37-
with:
38-
version: ${{ inputs.version }}
39-
generic_tag: ${{ inputs.generic_tag }}
54+
- name: Login to ghcr.io
55+
if: matrix.registry == 'ghcr.io'
56+
uses: docker/login-action@v3
57+
with:
58+
registry: ${{ matrix.registry }}
59+
username: ${{ github.actor }}
60+
password: ${{ secrets.GITHUB_TOKEN }}
61+
62+
- name: Configure AWS credentials
63+
if: matrix.registry == 'ecr'
64+
uses: aws-actions/configure-aws-credentials@v4
65+
with:
66+
aws-region: us-east-1 # This region only for public ECR
67+
role-to-assume: ${{ secrets.AWS_ROLE }}
68+
69+
- name: Login to public ECR
70+
if: matrix.registry == 'ecr'
71+
id: login-ecr-public
72+
uses: aws-actions/amazon-ecr-login@v2
73+
with:
74+
registry-type: public
75+
76+
- name: define env vars
77+
run: |
78+
if [ ${{matrix.registry }} == 'docker.io' ]; then
79+
echo "REGISTRY=${{ matrix.registry }}" >> $GITHUB_ENV
80+
echo "REPOSITORY=${{ github.repository }}" >> $GITHUB_ENV
81+
elif [ ${{ matrix.registry }} == 'ghcr.io' ]; then
82+
echo "REGISTRY=${{ matrix.registry }}" >> $GITHUB_ENV
83+
echo "REPOSITORY=${{ github.repository }}" >> $GITHUB_ENV
84+
elif [ ${{ matrix.registry }} == 'ecr' ]; then
85+
echo "REGISTRY=${{ steps.login-ecr-public.outputs.registry }}" >> $GITHUB_ENV
86+
echo "REPOSITORY=${{ github.repository }}" >> $GITHUB_ENV
87+
else
88+
echo "REGISTRY=" >> $GITHUB_ENV
89+
echo "REPOSITORY=notworking" >> $GITHUB_ENV
90+
fi
91+
92+
- name: Push images to ${{ matrix.registry }}
93+
run: |
94+
docker tag kafka-ui:temp ${{ env.REGISTRY }}/${{ env.REPOSITORY }}:${{ inputs.generic_tag }}
95+
docker tag kafka-ui:temp ${{ env.REGISTRY }}/${{ env.REPOSITORY }}:${{ inputs.version }}
96+
docker push ${{ env.REGISTRY }}/${{ env.REPOSITORY }}:${{ inputs.generic_tag }}
97+
docker push ${{ env.REGISTRY }}/${{ env.REPOSITORY }}:${{ inputs.version }}

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
sha: ${{ github.sha }}
5959
version: ${{ needs.jar-build.outputs.version }}
6060

61-
docker-deploy:
61+
docker-deploy:
6262
needs: [jar-build, docker-build]
6363
permissions:
6464
contents: read # To read secrets

0 commit comments

Comments
 (0)