ci(cross build): fix login error for aws ecr

This commit is contained in:
zhanghongtong 2022-03-14 13:49:46 +08:00
parent 4c93a71446
commit d3f05d35a8
1 changed files with 20 additions and 16 deletions

View File

@ -427,8 +427,7 @@ jobs:
- uses: docker/build-push-action@v2 - uses: docker/build-push-action@v2
with: with:
push: > push: >
${{ (github.event_name == 'release' && !github.event.release.prerelease) ${{ (github.event_name == 'release' && !github.event.release.prerelease) }}
|| (github.event.repository.owner != 'emqx' && startsWith(github.ref_name, 'ci/')) }}
pull: true pull: true
no-cache: true no-cache: true
platforms: linux/${{ matrix.arch }} platforms: linux/${{ matrix.arch }}
@ -442,22 +441,22 @@ jobs:
context: source context: source
- uses: aws-actions/configure-aws-credentials@v1 - uses: aws-actions/configure-aws-credentials@v1
if: matrix.profile == 'emqx'
with: with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_DEFAULT_REGION }} aws-region: ${{ secrets.AWS_DEFAULT_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
with:
registries: "public.ecr.aws"
- name: Docker push to aws ecr - name: Docker push to aws ecr
if: > if: matrix.profile == 'emqx' && matrix.arch == 'amd64' && startsWith(github.ref, 'refs/tags/')
${{ (github.event_name == 'release' && !github.event.release.prerelease && matrix.profile == 'emqx')
|| (github.event.repository.owner != 'emqx' && startsWith(github.ref_name, 'ci/')) }}
run: | run: |
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws IsPushLatest=${{ github.event_name == 'release' && !github.event.release.prerelease }};
for tag in $(echo ${{ steps.meta.outputs.json }} | jq -c '.tags[]'); do scripts/docker-create-push-manifests.sh "${{ steps.login-ecr.outputs.registry }}/${{ steps.meta.outputs.tags }}" "$IsPushLatest"
docker pull "$tag"
docker tag "$tag" "public.ecr.aws/$tag"
docker push "public.ecr.aws/$tag"
done
docker-push-multi-arch-manifest: docker-push-multi-arch-manifest:
# note, we only run on amd64 # note, we only run on amd64
@ -563,17 +562,22 @@ jobs:
scripts/docker-create-push-manifests.sh "${{ steps.meta.outputs.tags }}" "$IsPushLatest" scripts/docker-create-push-manifests.sh "${{ steps.meta.outputs.tags }}" "$IsPushLatest"
- uses: aws-actions/configure-aws-credentials@v1 - uses: aws-actions/configure-aws-credentials@v1
if: matrix.profile == 'emqx' && matrix.arch == 'amd64'
with: with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_DEFAULT_REGION }} aws-region: ${{ secrets.AWS_DEFAULT_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
with:
registries: "public.ecr.aws"
- name: Docker push to aws ecr - name: Docker push to aws ecr
if: matrix.profile == 'emqx' && matrix.arch == 'amd64' if: matrix.profile == 'emqx' && matrix.arch == 'amd64' && startsWith(github.ref, 'refs/tags/')
run: | run: |
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws
IsPushLatest=${{ github.event_name == 'release' && !github.event.release.prerelease }}; IsPushLatest=${{ github.event_name == 'release' && !github.event.release.prerelease }};
scripts/docker-create-push-manifests.sh "public.ecr.aws/${{ steps.meta.outputs.tags }}" "$IsPushLatest" scripts/docker-create-push-manifests.sh "${{ steps.login-ecr.outputs.registry }}/${{ steps.meta.outputs.tags }}" "$IsPushLatest"
upload: upload:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04