メモ: ECRのdockerイメージのタグを更新するGitHub Actions

  docker-tag:
    name: Tag docker images
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: aws-actions/configure-aws-credentials@v2
        with:
          #...
      - name: Tag branch to docker images
        run: |
          MANIFEST=$(aws ecr batch-get-image --repository-name my-repo --image-ids imageTag=${{ github.sha }} --output json | jq --raw-output --join-output '.images[0].imageManifest')
          aws ecr put-image --repository-name my-repo --image-tag latest --image-manifest "$MANIFEST"