variables:
  APP_NAME: postamates_front
  IMAGE_NAME: $CI_REGISTRY_IMAGE

stages:
  # - build
  - deploy

# .build: &build-common
#   stage: build
#   before_script:
#     - sudo docker login -u $CI_DEPLOY_USER -p $CI_DEPLOY_PASSWORD $CI_REGISTRY
#   script:
#     - sudo docker pull $IMAGE_NAME:builder || true
#     - sudo docker pull $IMAGE_NAME:$CI_COMMIT_SHORT_SHA || true
#     - sudo docker build --cache-from $IMAGE_NAME:builder --target builder  --memory=1000m --memory-swap=5000m --tag $IMAGE_NAME:builder .
#     - sudo docker push $IMAGE_NAME:builder
#     - sudo docker build --cache-from $IMAGE_NAME:builder --cache-from $IMAGE_NAME:$CI_COMMIT_SHORT_SHA --tag $IMAGE_NAME:$IMAGE_TAG --build-arg REACT_APP_DOMAIN_URL=$REACT_APP_DOMAIN_URL --build-arg BUILDKIT_INLINE_CACHE=1 .
#     - sudo docker push $IMAGE_NAME:$IMAGE_TAG
#   tags:
#     - deploy-remote

# build-test-job:
#   <<:  *build-common
#   variables: 
#     IMAGE_TAG: $CI_COMMIT_SHORT_SHA
#     REACT_APP_DOMAIN_URL: https://$DOMAIN/
#   rules:
#     - if: $CI_COMMIT_BRANCH == "sst_main"

# .deploy: &deploy-common
#   stage: deploy
#   before_script:
#     - sudo docker login -u $CI_DEPLOY_USER -p $CI_DEPLOY_PASSWORD $CI_REGISTRY
#   script:
#     - sudo docker cp $IMAGE_NAME:$IMAGE_TAG:/opt/site /home/toren332/sst_postamates_frontend/dist
#   tags:
#     - deploy-remote

# deploy-test-job:
#   <<: *deploy-common
#   variables:
#     IMAGE_TAG: $CI_COMMIT_SHORT_SHA
#   rules:
#     - if: $CI_COMMIT_BRANCH == "sst_main"

deploy:
  stage: deploy
  script: 
    - sudo cp -R ./dist /home/toren332/sst_postamates_frontend
  tags:
    - deploy-remote
  rules:
    - if: $CI_COMMIT_BRANCH == "sst_main"