Continuous integration Github操作:aws ecr登录失败
我正在尝试为我的github存储库设置CI。在每个推入式沙箱分支之后,我希望在我的项目中构建一个docker映像,并推送到AWS ECR 这是我的.github/workflows/aws.yml文件-Continuous integration Github操作:aws ecr登录失败,continuous-integration,github-actions,aws-ecr,Continuous Integration,Github Actions,Aws Ecr,我正在尝试为我的github存储库设置CI。在每个推入式沙箱分支之后,我希望在我的项目中构建一个docker映像,并推送到AWS ECR 这是我的.github/workflows/aws.yml文件- name: be-harvester CI on: pull_request: branches: - sandbox push: branches: - sandbox env: AWS_REPOSITO
name: be-harvester CI
on:
pull_request:
branches:
- sandbox
push:
branches:
- sandbox
env:
AWS_REPOSITORY_URL: ${{ secrets.AWS_REPOSITORY_URL }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
jobs:
build-and-push:
name: Build and push image to AWS ECR
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@master
- name: Check REPO url
run: echo $AWS_REPOSITORY_URL
- name: Setup ECR
run: $( aws ecr get-login --no-include-email --region ap-south-1)
- name: Build and tag the image
run: docker build -t $AWS_REPOSITORY_URL .
- name: Push
run: docker push $REPOSITORY_URL
在aws ecr登录步骤中构建失败,以下是构建日志的屏幕截图。
此错误的原因是什么?使用AWS的官方操作:
jobs:
build:
steps:
# see: https://github.com/aws-actions/configure-aws-credentials
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
# see: https://github.com/aws-actions/amazon-ecr-login
- name: Log in to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build, tag, and push image to Amazon ECR
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: reponame
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
- name: Log out of Amazon ECR
if: always()
run: docker logout ${{ steps.login-ecr.outputs.registry }}