Ask questionsSet `tag` dynamically causes failure

Orb version

6.3.0 <!--- e.g., 1.0.0 find this information in your config.yml file; if the version is @volatile, check the top of your CircleCI-generated, expanded configuration file, viewable from the "Configuration" tab of any job page, for the orb's specific semantic version number -->

What happened

Build fails as version tagged locally is different than version trying to be pushed.

<!--- please include any relevant links to CircleCI workflows or jobs where you saw this behavior --> image

Expected behavior

Tag should be the same

<!--- what should happen, ideally? -->


  aws-ecr: circleci/aws-ecr@6.3.0
version: 2.1

  # Build and push to ECR on builds to master
      - aws-ecr/build-and-push-image:
          account-url: AWS_ACCOUNT_URL
          aws-access-key-id: AWS_ACCESS_KEY_ID
          aws-secret-access-key: AWS_SECRET_ACCESS_KEY
          region: AWS_REGION
          repo: node
          tag: $(date -u +"%Y-%m-%dT%H%M%SZ") # ISO 8601 date format

Answer questions jf

Thank you for coming up with this, @toymachiner62 . I didnt even think that we could have a dynamic tag this way!!

I've improved upon this and fixed the way to keep the tag constant between the build and push steps:

      - run:
          name: seed environment
          command: |
            echo $(date +%Y-%m-%d__%H-%M)__$(git log -n1 --format=%h) > IMAGE_TAG
      - aws-ecr/build-and-push-image:
          tag: $(cat IMAGE_TAG)

This works and gives you a stable tag in the environment. Really all you need is a a stable tag between "Build docker image" and "Push image to Amazon ECR". The format of the tag is entirely up to you, but I like having the datetime + hash reflected


Related questions

Support for layer caching? - aws-ecr-orb hot 1
can't pass the check by command "circleci config process .circleci/config.yml" hot 1
Github User Rank List