version: 2
jobs:
  cansetup:
    machine:
      enabled: true
      image: ubuntu-2204:current
    steps:
      - checkout
      - run:
          command: |
            cd .circleci
            sudo ./test-install.sh
  # Define in CircleCi Project Variables: $DOCKERHUB_REPO, $DOCKERHUB_USER, $DOCKERHUB_PASS
  # Publish jobs require those variables
  docker:
    docker:
      - image: cimg/base:stable
    steps:
      - setup_remote_docker
      - checkout
      - run:
          command: |
            cd docker-compose-generator
            docker login --username=$DOCKERHUB_USER --password=$DOCKERHUB_PASS
            docker buildx create --use
            DOCKER_BUILDX_OPTS="--platform linux/amd64,linux/arm64,linux/arm/v7 --push"
            docker buildx build $DOCKER_BUILDX_OPTS -t $DOCKERHUB_REPO:latest .

workflows:
  version: 2
  publish:
    jobs:
      - cansetup:
          filters:
            branches:
              only: master
      - docker:
          filters:
            branches:
              only: dcg-latest
