|
20 | 20 | strategy:
|
21 | 21 | fail-fast: false
|
22 | 22 | matrix:
|
23 |
| - registry: [ 'docker.io', 'ghcr.io', 'ecr' ] |
| 23 | + registry: [ 'docker.io', 'ghcr.io', 'public.ecr.aws' ] |
24 | 24 |
|
25 | 25 | runs-on: ubuntu-latest
|
26 | 26 | steps:
|
|
31 | 31 | name: image
|
32 | 32 | path: /tmp
|
33 | 33 |
|
34 |
| - # setup containerd to preserve provenance attestations :https://docs.docker.com/build/attestations/#creating-attestations |
| 34 | + # setup containerd to preserve provenance attestations: |
| 35 | + # https://docs.docker.com/build/attestations/#creating-attestations |
35 | 36 | - name: Setup docker with containerd
|
36 | 37 | uses: crazy-max/ghaction-setup-docker@v3
|
37 | 38 | with:
|
@@ -63,33 +64,33 @@ jobs:
|
63 | 64 | password: ${{ secrets.GITHUB_TOKEN }}
|
64 | 65 |
|
65 | 66 | - name: Configure AWS credentials
|
66 |
| - if: matrix.registry == 'ecr' |
| 67 | + if: matrix.registry == 'public.ecr.aws' |
67 | 68 | uses: aws-actions/configure-aws-credentials@v4
|
68 | 69 | with:
|
69 | 70 | aws-region: us-east-1 # This region only for public ECR
|
70 | 71 | role-to-assume: ${{ secrets.AWS_ROLE }}
|
71 | 72 |
|
72 | 73 | - name: Login to public ECR
|
73 |
| - if: matrix.registry == 'ecr' |
| 74 | + if: matrix.registry == 'public.ecr.aws' |
74 | 75 | id: login-ecr-public
|
75 | 76 | uses: aws-actions/amazon-ecr-login@v2
|
76 | 77 | with:
|
77 | 78 | registry-type: public
|
78 | 79 |
|
79 |
| - - name: define env vars |
| 80 | + - name: Define env vars for container registry URL |
80 | 81 | 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 |
| 82 | + if [ ${{ matrix.registry }} == 'public.ecr.aws' ]; then |
| 83 | + # vars.ECR_REGISTRY value is expected to be of the `public.ecr.aws/<public_ecr_id>` form |
| 84 | + # The `public_ecr_id` must be a *default* alias associated with public regsitry (rather |
| 85 | + # than a custom alias) |
88 | 86 | echo "REGISTRY=${{ vars.ECR_REGISTRY }}" >> $GITHUB_ENV
|
| 87 | + # Trim GH Org name so that resulting Public ECR URL has no duplicate org name |
| 88 | + # Public ECR default alias: public.ecr.aws/<public_ecr_id>/kafka-ui |
| 89 | + # Public ECR custom alias: public.ecr.aws/kafbat/kafka-ui |
| 90 | + echo "REPOSITORY=$(basename ${{ github.repository }})" >> $GITHUB_ENV |
| 91 | + else # this covers the case of docker.io and ghcr.io |
| 92 | + echo "REGISTRY=${{ matrix.registry }}" >> $GITHUB_ENV |
89 | 93 | echo "REPOSITORY=${{ github.repository }}" >> $GITHUB_ENV
|
90 |
| - else |
91 |
| - echo "REGISTRY=" >> $GITHUB_ENV |
92 |
| - echo "REPOSITORY=notworking" >> $GITHUB_ENV |
93 | 94 | fi
|
94 | 95 |
|
95 | 96 | - name: Push images to ${{ matrix.registry }}
|
|
0 commit comments