forked from kafbat/kafka-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
100 lines (87 loc) · 3.2 KB
/
docker_publish.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
name: "Docker publish"
on:
workflow_call:
inputs:
version:
required: true
type: string
generic_tag:
required: true
type: string
permissions:
packages: write
id-token: write # Required to authenticate with OIDC for AWS
jobs:
deploy:
continue-on-error: true
strategy:
fail-fast: false
matrix:
registry: [ 'docker.io', 'ghcr.io', 'ecr' ]
runs-on: ubuntu-latest
steps:
- name: Download docker image
uses: actions/download-artifact@v4
with:
name: image
path: /tmp
# setup containerd to preserve provenance attestations :https://docs.docker.com/build/attestations/#creating-attestations
- name: Setup docker with containerd
uses: crazy-max/ghaction-setup-docker@v3
with:
daemon-config: |
{
"features": {
"containerd-snapshotter": true
}
}
- name: Load docker image into daemon
run: |
docker load --input /tmp/image.tar
- name: Login to docker.io
if: matrix.registry == 'docker.io'
uses: docker/login-action@v3
with:
registry: ${{ matrix.registry }}
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to ghcr.io
if: matrix.registry == 'ghcr.io'
uses: docker/login-action@v3
with:
registry: ${{ matrix.registry }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Configure AWS credentials
if: matrix.registry == 'ecr'
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-east-1 # This region only for public ECR
role-to-assume: ${{ secrets.AWS_ROLE }}
- name: Login to public ECR
if: matrix.registry == 'ecr'
id: login-ecr-public
uses: aws-actions/amazon-ecr-login@v2
with:
registry-type: public
- name: define env vars
run: |
if [ ${{matrix.registry }} == 'docker.io' ]; then
echo "REGISTRY=${{ matrix.registry }}" >> $GITHUB_ENV
echo "REPOSITORY=${{ github.repository }}" >> $GITHUB_ENV
elif [ ${{ matrix.registry }} == 'ghcr.io' ]; then
echo "REGISTRY=${{ matrix.registry }}" >> $GITHUB_ENV
echo "REPOSITORY=${{ github.repository }}" >> $GITHUB_ENV
elif [ ${{ matrix.registry }} == 'ecr' ]; then
echo "REGISTRY=${{ vars.ECR_REGISTRY }}" >> $GITHUB_ENV
echo "REPOSITORY=${{ github.repository }}" >> $GITHUB_ENV
else
echo "REGISTRY=" >> $GITHUB_ENV
echo "REPOSITORY=notworking" >> $GITHUB_ENV
fi
- name: Push images to ${{ matrix.registry }}
run: |
docker tag kafka-ui:temp ${{ env.REGISTRY }}/${{ env.REPOSITORY }}:${{ inputs.generic_tag }}
docker tag kafka-ui:temp ${{ env.REGISTRY }}/${{ env.REPOSITORY }}:${{ inputs.version }}
docker push ${{ env.REGISTRY }}/${{ env.REPOSITORY }}:${{ inputs.generic_tag }}
docker push ${{ env.REGISTRY }}/${{ env.REPOSITORY }}:${{ inputs.version }}