GitHub Action registering new ECS task definition


I am trying to migrate from in-house Jenkins to GitHub actions for our CI-CD pipelines.
I have created an ‘action.yml’ file in the ‘.github/workflows/’ folder.
The job builds 2 separate docker containers, tagging them both twice and then pushing to AWS ECR which all works fine.

The error I am getting is from the below:

    name: Deploy to ECS
    runs-on: ubuntu-latest
    needs: [Build_Push_Docker_Images]
      - uses: actions/checkout@v2

      - name: Get short SHA
        id: slug
        run: echo "::set-output name=sha7::$(echo ${GITHUB_SHA} | cut -c1-7)"

      - name: Render Amazon ECS task definition for php-fpm container
        id: render-php-container
        uses: aws-actions/amazon-ecs-render-task-definition@v1
          task-definition: task-definition.json
          container-name: "php-fpm"
          image: "${{ env.AWS_ACCOUNT_ID }}.dkr.ecr.${{ env.AWS_DEFAULT_REGION }}${{ env.IMAGEPHPFPM }}:${{ steps.slug.outputs.sha7 }}"

The error I get is: /home/runner/work/the-first/the-first/task-definition.json: Unexpected token � in JSON at position 0
The file is valid json, I have checked over and over again and I am at a loss on how to proceed. Using normal aws cmd line tools with this task-definition.json file successfully registers a new task definition in ECS.
Debug logs don’t shed any more light on the situation either.
Any help would be much appreciated.


Hi @tsposato, welcome to the GitHub Support Community!

I’m wondering if this is an issue with the aws-actions/amazon-ecs-render-task-definition action itself rather than an issue with your workflow? If you’re saying this same JSON file works when using it from the aws cli but doesn’t when you use this action it sounds like there may be a problem with this action consuming the JSON file.

It may be worth opening an issue for this inside the repository for this action. They’ll likely have a better idea of what’s going wrong and whether it is something wrong with the action itself or something wrong with your workflow.

1 Like

Hi @thomasshaped, thanks!
I feel a bit silly now but it seems like my IDE is doing something strange with the JSON file and causing this issue. When I use the aws cli on the JSON file in my github repo I do indeed get the error that it is receiving invalid JSON. Which is quite strange. I’m still trying to figure out why. If I copy and paste it into an external JSON validator it comes up as valid JSON. I guess I’ll continue to try and figure out why.

1 Like

Ok, the problem was the encoding of the file was not ‘UTF-8’. Once I changed the encoding of the file I was able to register a Task Definition successfully with the aws cli and with the github action aws-actions/amazon-ecs-render-task-definition.


1 Like