Github 操作错误:需要输入但未提供:任务定义

时间:2021-04-25 18:35:45

标签: amazon-ecs github-actions

aws

[![在此处输入图片描述][2]][2]

  on:
    push:
      branches:
        - soubhagya

  name: Deploy to Amazon ECS

  jobs:
    deploy:
      name: Deploy
      runs-on: ubuntu-latest
      environment: production

      steps:
        - name: Checkout
          uses: actions/checkout@v2

        - 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: af-south-1

        - name: Login to Amazon ECR
          id: login-ecr
          uses: aws-actions/amazon-ecr-login@v1

        - name: Build, tag, and push image to Amazon ECR
          id: build-image
          env:
            ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
            ECR_REPOSITORY: new-cgafrica-backend
            IMAGE_TAG: ${{ github.sha }}
          run: |
            # Build a docker container and
            # push it to ECR so that it can
            # be deployed to ECS.
            docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
            docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
            echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"

        - name: Fill in the new image ID in the Amazon ECS task definition
          id: cgafrica-new-backend-task
          uses: aws-actions/amazon-ecs-render-task-definition@v1
          with:
            task-definition: task-definition.json
            container-name: cgafrica-backend-container
            image: ${{ steps.build-image.outputs.image }}

        - name: Deploy Amazon ECS task definition
          uses: aws-actions/amazon-ecs-deploy-task-definition@v1
          with:
            task-definition: ${{ steps.task-def.outputs.task-definition }}
            service: cgafrica-backend-service
            cluster: cgafrica-backend-cluster
            wait-for-service-stability: true

这是我添加的 yaml 文件代码。请检查

我已经分享了我的 task-definition.json 和 github 操作管道进度。 但是,我收到了一些错误需要输入但未提供:任务定义 请让我知道这里有什么问题

1 个答案:

答案 0 :(得分:0)

问题出在最后一步 - Deploy Amazon ECS task definition

有问题的部分是 ${{ steps.task-def.outputs.task-definition }},它不涉及现有步骤。没有 ID 为 task-def 的步骤。

为了工作,它应该是:${{ steps.cgafrica-new-backend-task.outputs.task-definition }}

- name: Deploy Amazon ECS task definition
  uses: aws-actions/amazon-ecs-deploy-task-definition@v1
  with:
    task-definition: ${{ steps.cgafrica-new-backend-task.outputs.task-definition }}
    service: cgafrica-backend-service
    cluster: cgafrica-backend-cluster
    wait-for-service-stability: true
相关问题