Loading .gitlab-ci.yml +121 −25 Original line number Original line Diff line number Diff line Loading @@ -8,7 +8,9 @@ stages: - test - test - prepare - prepare - review - review - deploy - deploy:staging - deploy:canary - deploy:production cache: cache: paths: paths: Loading @@ -33,21 +35,49 @@ test: script: script: - bin/phpspec run - bin/phpspec run lint: stage: test image: minds/php-tests:latest script: - bin/php-cs-fixer fix --allow-risky=yes --verbose --dry-run prepare:fpm: prepare:fpm: stage: prepare stage: prepare image: minds/ci:latest image: minds/ci:latest script: script: - docker login -u gitlab-ci-token -p ${CI_BUILD_TOKEN} ${CI_REGISTRY} - docker login -u gitlab-ci-token -p ${CI_BUILD_TOKEN} ${CI_REGISTRY} - docker build -t $CI_REGISTRY_IMAGE/fpm:$CI_BUILD_REF -f containers/php-fpm/Dockerfile . - | - docker push $CI_REGISTRY_IMAGE/fpm:$CI_BUILD_REF docker build \ -t $CI_REGISTRY_IMAGE/fpm:$CI_PIPELINE_ID \ -f containers/php-fpm/Dockerfile \ --build-arg MINDS_VERSION=$CI_PIPELINE_ID \ --build-arg SENTRY_DSN=$SENTRY_DSN \ . - docker push $CI_REGISTRY_IMAGE/fpm:$CI_PIPELINE_ID prepare:runners: prepare:runners: stage: prepare stage: prepare image: minds/ci:latest image: minds/ci:latest script: script: - docker login -u gitlab-ci-token -p ${CI_BUILD_TOKEN} ${CI_REGISTRY} - docker login -u gitlab-ci-token -p ${CI_BUILD_TOKEN} ${CI_REGISTRY} - docker build -t $CI_REGISTRY_IMAGE/runners:$CI_BUILD_REF -f containers/php-runners/Dockerfile . - | - docker push $CI_REGISTRY_IMAGE/runners:$CI_BUILD_REF docker build \ -t $CI_REGISTRY_IMAGE/runners:$CI_PIPELINE_ID \ -f containers/php-runners/Dockerfile \ --build-arg MINDS_VERSION=$CI_PIPELINE_ID \ --build-arg SENTRY_DSN=$SENTRY_DSN \ . - docker push $CI_REGISTRY_IMAGE/runners:$CI_PIPELINE_ID prepare:all:sentry: stage: prepare image: getsentry/sentry-cli script: - echo "Create a new release $CI_PIPELINE_ID" - sentry-cli releases new $CI_PIPELINE_ID - sentry-cli releases set-commits --auto $CI_PIPELINE_ID - sentry-cli releases finalize $CI_PIPELINE_ID - echo "Finalized release for $CI_PIPELINE_ID" review:start: review:start: stage: review stage: review Loading @@ -55,18 +85,21 @@ review:start: script: script: - aws eks update-kubeconfig --name=sandbox - aws eks update-kubeconfig --name=sandbox - git clone --branch=sandbox-wip https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/minds/helm-charts.git - git clone --branch=sandbox-wip https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/minds/helm-charts.git - echo "Upgrading helm for pipeline ${CI_PIPELINE_ID}" - echo "Setting to image ${CI_REGISTRY_IMAGE}" - "helm upgrade \ - "helm upgrade \ --install \ --install \ --reuse-values \ --reuse-values \ --set phpfpm.image.repository=$CI_REGISTRY_IMAGE/fpm \ --set phpfpm.image.repository=$CI_REGISTRY_IMAGE/fpm \ --set phpfpm.image.tag=$CI_BUILD_REF \ --set-string phpfpm.image.tag=$CI_PIPELINE_ID \ --set runners.image.repository=$CI_REGISTRY_IMAGE/runners \ --set runners.image.repository=$CI_REGISTRY_IMAGE/runners \ --set runners.image.tag=$CI_BUILD_REF \ --set-string runners.image.tag=$CI_PIPELINE_ID \ --set domain=$CI_BUILD_REF_SLUG.$KUBE_INGRESS_BASE_DOMAIN \ --set domain=$CI_BUILD_REF_SLUG.$KUBE_INGRESS_BASE_DOMAIN \ --set elasticsearch.clusterName=$CI_BUILD_REF_SLUG-elasticsearch \ --set elasticsearch.clusterName=$CI_BUILD_REF_SLUG-elasticsearch \ --wait \ --wait \ $CI_BUILD_REF_SLUG \ $CI_BUILD_REF_SLUG \ ./helm-charts/minds" ./helm-charts/minds" - sentry-cli releases deploys $CI_PIPELINE_ID new -e review-$CI_COMMIT_REF_SLUG environment: environment: name: review/$CI_COMMIT_REF_NAME name: review/$CI_COMMIT_REF_NAME url: https://$CI_BUILD_REF_SLUG.$KUBE_INGRESS_BASE_DOMAIN url: https://$CI_BUILD_REF_SLUG.$KUBE_INGRESS_BASE_DOMAIN Loading Loading @@ -94,44 +127,107 @@ review:stop: - master - master - test/gitlab-ci - test/gitlab-ci deploy:fpm: staging:fpm: stage: deploy stage: deploy:staging image: minds/ci:latest script: - IMAGE_LABEL="staging" - $(aws ecr get-login --no-include-email --region us-east-1) - docker login -u gitlab-ci-token -p ${CI_BUILD_TOKEN} ${CI_REGISTRY} - docker pull $CI_REGISTRY_IMAGE/fpm:$CI_PIPELINE_ID # Push to AWS registry - docker tag $CI_REGISTRY_IMAGE/fpm:$CI_PIPELINE_ID $ECR_REPOSITORY_URL_FPM:$IMAGE_LABEL - docker push $ECR_REPOSITORY_URL_FPM:$IMAGE_LABEL # Push to Gitlab registry - docker tag $CI_REGISTRY_IMAGE/fpm:$CI_PIPELINE_ID $CI_REGISTRY_IMAGE/fpm:$IMAGE_LABEL - docker push $CI_REGISTRY_IMAGE/fpm:$IMAGE_LABEL # Deploy to staging - aws ecs update-service --service=$ECS_APP_STAGING_SERVICE --force-new-deployment --region us-east-1 --cluster=$ECS_CLUSTER # Update sentry - sentry-cli releases deploys $CI_PIPELINE_ID new -e $IMAGE_LABEL environment: name: staging url: https://www.minds.com/?staging=1 only: refs: - master - test/gitlab-ci canary:fpm: stage: deploy:canary image: minds/ci:latest script: - IMAGE_LABEL="canary" - $(aws ecr get-login --no-include-email --region us-east-1) - docker login -u gitlab-ci-token -p ${CI_BUILD_TOKEN} ${CI_REGISTRY} - docker pull $CI_REGISTRY_IMAGE/fpm:$CI_PIPELINE_ID # Push to AWS registry - docker tag $CI_REGISTRY_IMAGE/fpm:$CI_PIPELINE_ID $ECR_REPOSITORY_URL_FPM:$IMAGE_LABEL - docker push $ECR_REPOSITORY_URL_FPM:$IMAGE_LABEL # Push to Gitlab registry - docker tag $CI_REGISTRY_IMAGE/fpm:$CI_PIPELINE_ID $CI_REGISTRY_IMAGE/fpm:$IMAGE_LABEL - docker push $CI_REGISTRY_IMAGE/fpm:$IMAGE_LABEL # Deploy to ECS - aws ecs update-service --service=$ECS_APP_CANARY_SERVICE --force-new-deployment --region us-east-1 --cluster=$ECS_CLUSTER # Update sentry - sentry-cli releases deploys $CI_PIPELINE_ID new -e $IMAGE_LABEL only: refs: - master - test/gitlab-ci environment: name: canary url: https://www.minds.com/?canary=1 # requires canary cookie when: manual allow_failure: false # prevents auto deploy to full production production:fpm: stage: deploy:production image: minds/ci:latest image: minds/ci:latest script: script: - IMAGE_LABEL="production" - $(aws ecr get-login --no-include-email --region us-east-1) - $(aws ecr get-login --no-include-email --region us-east-1) - docker login -u gitlab-ci-token -p ${CI_BUILD_TOKEN} ${CI_REGISTRY} - docker login -u gitlab-ci-token -p ${CI_BUILD_TOKEN} ${CI_REGISTRY} - docker pull $CI_REGISTRY_IMAGE/fpm:$CI_BUILD_REF - docker pull $CI_REGISTRY_IMAGE/fpm:$CI_PIPELINE_ID # Push to production registry # Push to AWS registry - docker tag $CI_REGISTRY_IMAGE/fpm:$CI_BUILD_REF $REPOSITORY_URL_FPM - docker tag $CI_REGISTRY_IMAGE/fpm:$CI_PIPELINE_ID $ECR_REPOSITORY_URL_FPM:$IMAGE_LABEL - docker push $REPOSITORY_URL_FPM - docker push $ECR_REPOSITORY_URL_FPM:$IMAGE_LABEL # Push to gitlab register # Push to Gitlab registry - docker tag $CI_REGISTRY_IMAGE/fpm:$CI_BUILD_REF $CI_REGISTRY_IMAGE/fpm:latest - docker tag $CI_REGISTRY_IMAGE/fpm:$CI_PIPELINE_ID $CI_REGISTRY_IMAGE/fpm:$IMAGE_LABEL - docker push $CI_REGISTRY_IMAGE/fpm:latest - docker push $CI_REGISTRY_IMAGE/fpm:$IMAGE_LABEL - aws ecs update-service --service=$SERVICE_FPM --force-new-deployment --region us-east-1 --cluster=$CLUSTER # Delpoy to ECS - aws ecs update-service --service=$ECS_APP_PRODUCTION_SERVICE --force-new-deployment --region us-east-1 --cluster=$ECS_CLUSTER # Update sentry - sentry-cli releases deploys $CI_PIPELINE_ID new -e $IMAGE_LABEL only: only: refs: refs: - master - master - test/gitlab-ci - test/gitlab-ci environment: environment: name: production name: production url: https://www.minds.com/ when: delayed start_in: 12 hours # reduce? can always be deployed manually earlier too deploy:runners: production:runners: stage: deploy stage: deploy:production image: minds/ci:latest image: minds/ci:latest script: script: - IMAGE_LABEL="production" - $(aws ecr get-login --no-include-email --region us-east-1) - $(aws ecr get-login --no-include-email --region us-east-1) - docker login -u gitlab-ci-token -p ${CI_BUILD_TOKEN} ${CI_REGISTRY} - docker login -u gitlab-ci-token -p ${CI_BUILD_TOKEN} ${CI_REGISTRY} - docker pull $CI_REGISTRY_IMAGE/runners:$CI_BUILD_REF - docker pull $CI_REGISTRY_IMAGE/runners:$CI_PIPELINE_ID # Push to production register # Push to production register - docker tag $CI_REGISTRY_IMAGE/runners:$CI_BUILD_REF $REPOSITORY_URL_RUNNERS - docker tag $CI_REGISTRY_IMAGE/runners:$CI_PIPELINE_ID $ECR_REPOSITORY_URL_RUNNERS:$IMAGE_LABEL - docker push $REPOSITORY_URL_RUNNERS - docker push $ECR_REPOSITORY_URL_RUNNERS:$IMAGE_LABEL # Push gitlab registry # Push gitlab registry - docker tag $CI_REGISTRY_IMAGE/runners:$CI_BUILD_REF $CI_REGISTRY_IMAGE/runners:latest - docker tag $CI_REGISTRY_IMAGE/runners:$CI_PIPELINE_ID $CI_REGISTRY_IMAGE/runners:$IMAGE_LABEL - docker push $CI_REGISTRY_IMAGE/runners:latest - docker push $CI_REGISTRY_IMAGE/runners:$IMAGE_LABEL - aws ecs update-service --service=$SERVICE_RUNNERS --force-new-deployment --region us-east-1 --cluster=$CLUSTER - aws ecs update-service --service=$ECS_RUNNERS_PRODUCTION_SERVICE --force-new-deployment --region us-east-1 --cluster=$ECS_CLUSTER only: only: refs: refs: - master - master - test/gitlab-ci - test/gitlab-ci environment: environment: name: production name: production url: https://www.minds.com/ .php_cs +7 −2 Original line number Original line Diff line number Diff line Loading @@ -5,5 +5,10 @@ $finder = PhpCsFixer\Finder::create() ->in(__DIR__); ->in(__DIR__); return PhpCsFixer\Config::create() return PhpCsFixer\Config::create() ->fixers(['psr2', 'strict_param', 'short_array_syntax', 'no_blank_lines_after_class_opening']) ->setRules([ ->finder($finder); '@PSR2' => true, 'strict_param' => true, 'array_syntax' => ['syntax' => 'short'], 'no_blank_lines_after_class_opening' => true, ]) ->setFinder($finder); Api/Exportable.php +4 −0 Original line number Original line Diff line number Diff line Loading @@ -118,6 +118,10 @@ class Exportable implements \JsonSerializable $exported['ownerObj']['guid'] = (string) $exported['ownerObj']['guid']; $exported['ownerObj']['guid'] = (string) $exported['ownerObj']['guid']; } } if (isset($exported['urn']) && isset($_SERVER['HTTP_APP_VERSION'])) { $exported['urn'] = "urn:entity:{$exported['guid']}"; } foreach ($this->exceptions as $exception) { foreach ($this->exceptions as $exception) { $exported[$exception] = $item->{$exception}; $exported[$exception] = $item->{$exception}; } } Loading Api/Factory.php +11 −11 Original line number Original line Diff line number Diff line Loading @@ -50,7 +50,7 @@ class Factory if (!$handler instanceof Interfaces\ApiIgnorePam) { if (!$handler instanceof Interfaces\ApiIgnorePam) { self::pamCheck($request, $response); self::pamCheck($request, $response); } } $pages = array_splice($segments, $loop) ?: array(); $pages = array_splice($segments, $loop) ?: []; return $handler->$method($pages); return $handler->$method($pages); } } } } Loading @@ -65,7 +65,7 @@ class Factory if (!$handler instanceof Interfaces\ApiIgnorePam) { if (!$handler instanceof Interfaces\ApiIgnorePam) { self::pamCheck($request, $response); self::pamCheck($request, $response); } } $pages = array_splice($segments, $loop) ?: array(); $pages = array_splice($segments, $loop) ?: []; return $handler->$method($pages); return $handler->$method($pages); } } --$loop; --$loop; Loading Loading @@ -111,7 +111,7 @@ class Factory header('Content-type: application/json'); header('Content-type: application/json'); header("Access-Control-Allow-Origin: *"); header("Access-Control-Allow-Origin: *"); header('HTTP/1.1 401 Unauthorized', true, 401); header('HTTP/1.1 401 Unauthorized', true, 401); echo json_encode(array('error'=>'You are not an admin', 'code'=>401)); echo json_encode(['error'=>'You are not an admin', 'code'=>401]); exit; exit; } } } } Loading Loading @@ -143,11 +143,11 @@ class Factory * Builds an API response * Builds an API response * @param array $data * @param array $data */ */ public static function response($data = array()) public static function response($data = []) { { $data = array_merge(array( $data = array_merge([ 'status' => 'success', //should success be assumed? 'status' => 'success', //should success be assumed? ), $data); ], $data); ob_end_clean(); ob_end_clean(); Loading @@ -162,7 +162,7 @@ class Factory * @return array - an array of the entities * @return array - an array of the entities * @deprecated * @deprecated */ */ public static function exportable($entities, $exceptions = array(), $exportContext = false) public static function exportable($entities, $exceptions = [], $exportContext = false) { { if (!$entities) { if (!$entities) { return []; return []; Loading Api/Routes.php +1 −1 Original line number Original line Diff line number Diff line Loading @@ -6,7 +6,7 @@ namespace Minds\Api; */ */ class Routes class Routes { { public static $routes = array(); public static $routes = []; /** /** * Adds a custom API route resolution * Adds a custom API route resolution Loading Loading
.gitlab-ci.yml +121 −25 Original line number Original line Diff line number Diff line Loading @@ -8,7 +8,9 @@ stages: - test - test - prepare - prepare - review - review - deploy - deploy:staging - deploy:canary - deploy:production cache: cache: paths: paths: Loading @@ -33,21 +35,49 @@ test: script: script: - bin/phpspec run - bin/phpspec run lint: stage: test image: minds/php-tests:latest script: - bin/php-cs-fixer fix --allow-risky=yes --verbose --dry-run prepare:fpm: prepare:fpm: stage: prepare stage: prepare image: minds/ci:latest image: minds/ci:latest script: script: - docker login -u gitlab-ci-token -p ${CI_BUILD_TOKEN} ${CI_REGISTRY} - docker login -u gitlab-ci-token -p ${CI_BUILD_TOKEN} ${CI_REGISTRY} - docker build -t $CI_REGISTRY_IMAGE/fpm:$CI_BUILD_REF -f containers/php-fpm/Dockerfile . - | - docker push $CI_REGISTRY_IMAGE/fpm:$CI_BUILD_REF docker build \ -t $CI_REGISTRY_IMAGE/fpm:$CI_PIPELINE_ID \ -f containers/php-fpm/Dockerfile \ --build-arg MINDS_VERSION=$CI_PIPELINE_ID \ --build-arg SENTRY_DSN=$SENTRY_DSN \ . - docker push $CI_REGISTRY_IMAGE/fpm:$CI_PIPELINE_ID prepare:runners: prepare:runners: stage: prepare stage: prepare image: minds/ci:latest image: minds/ci:latest script: script: - docker login -u gitlab-ci-token -p ${CI_BUILD_TOKEN} ${CI_REGISTRY} - docker login -u gitlab-ci-token -p ${CI_BUILD_TOKEN} ${CI_REGISTRY} - docker build -t $CI_REGISTRY_IMAGE/runners:$CI_BUILD_REF -f containers/php-runners/Dockerfile . - | - docker push $CI_REGISTRY_IMAGE/runners:$CI_BUILD_REF docker build \ -t $CI_REGISTRY_IMAGE/runners:$CI_PIPELINE_ID \ -f containers/php-runners/Dockerfile \ --build-arg MINDS_VERSION=$CI_PIPELINE_ID \ --build-arg SENTRY_DSN=$SENTRY_DSN \ . - docker push $CI_REGISTRY_IMAGE/runners:$CI_PIPELINE_ID prepare:all:sentry: stage: prepare image: getsentry/sentry-cli script: - echo "Create a new release $CI_PIPELINE_ID" - sentry-cli releases new $CI_PIPELINE_ID - sentry-cli releases set-commits --auto $CI_PIPELINE_ID - sentry-cli releases finalize $CI_PIPELINE_ID - echo "Finalized release for $CI_PIPELINE_ID" review:start: review:start: stage: review stage: review Loading @@ -55,18 +85,21 @@ review:start: script: script: - aws eks update-kubeconfig --name=sandbox - aws eks update-kubeconfig --name=sandbox - git clone --branch=sandbox-wip https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/minds/helm-charts.git - git clone --branch=sandbox-wip https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/minds/helm-charts.git - echo "Upgrading helm for pipeline ${CI_PIPELINE_ID}" - echo "Setting to image ${CI_REGISTRY_IMAGE}" - "helm upgrade \ - "helm upgrade \ --install \ --install \ --reuse-values \ --reuse-values \ --set phpfpm.image.repository=$CI_REGISTRY_IMAGE/fpm \ --set phpfpm.image.repository=$CI_REGISTRY_IMAGE/fpm \ --set phpfpm.image.tag=$CI_BUILD_REF \ --set-string phpfpm.image.tag=$CI_PIPELINE_ID \ --set runners.image.repository=$CI_REGISTRY_IMAGE/runners \ --set runners.image.repository=$CI_REGISTRY_IMAGE/runners \ --set runners.image.tag=$CI_BUILD_REF \ --set-string runners.image.tag=$CI_PIPELINE_ID \ --set domain=$CI_BUILD_REF_SLUG.$KUBE_INGRESS_BASE_DOMAIN \ --set domain=$CI_BUILD_REF_SLUG.$KUBE_INGRESS_BASE_DOMAIN \ --set elasticsearch.clusterName=$CI_BUILD_REF_SLUG-elasticsearch \ --set elasticsearch.clusterName=$CI_BUILD_REF_SLUG-elasticsearch \ --wait \ --wait \ $CI_BUILD_REF_SLUG \ $CI_BUILD_REF_SLUG \ ./helm-charts/minds" ./helm-charts/minds" - sentry-cli releases deploys $CI_PIPELINE_ID new -e review-$CI_COMMIT_REF_SLUG environment: environment: name: review/$CI_COMMIT_REF_NAME name: review/$CI_COMMIT_REF_NAME url: https://$CI_BUILD_REF_SLUG.$KUBE_INGRESS_BASE_DOMAIN url: https://$CI_BUILD_REF_SLUG.$KUBE_INGRESS_BASE_DOMAIN Loading Loading @@ -94,44 +127,107 @@ review:stop: - master - master - test/gitlab-ci - test/gitlab-ci deploy:fpm: staging:fpm: stage: deploy stage: deploy:staging image: minds/ci:latest script: - IMAGE_LABEL="staging" - $(aws ecr get-login --no-include-email --region us-east-1) - docker login -u gitlab-ci-token -p ${CI_BUILD_TOKEN} ${CI_REGISTRY} - docker pull $CI_REGISTRY_IMAGE/fpm:$CI_PIPELINE_ID # Push to AWS registry - docker tag $CI_REGISTRY_IMAGE/fpm:$CI_PIPELINE_ID $ECR_REPOSITORY_URL_FPM:$IMAGE_LABEL - docker push $ECR_REPOSITORY_URL_FPM:$IMAGE_LABEL # Push to Gitlab registry - docker tag $CI_REGISTRY_IMAGE/fpm:$CI_PIPELINE_ID $CI_REGISTRY_IMAGE/fpm:$IMAGE_LABEL - docker push $CI_REGISTRY_IMAGE/fpm:$IMAGE_LABEL # Deploy to staging - aws ecs update-service --service=$ECS_APP_STAGING_SERVICE --force-new-deployment --region us-east-1 --cluster=$ECS_CLUSTER # Update sentry - sentry-cli releases deploys $CI_PIPELINE_ID new -e $IMAGE_LABEL environment: name: staging url: https://www.minds.com/?staging=1 only: refs: - master - test/gitlab-ci canary:fpm: stage: deploy:canary image: minds/ci:latest script: - IMAGE_LABEL="canary" - $(aws ecr get-login --no-include-email --region us-east-1) - docker login -u gitlab-ci-token -p ${CI_BUILD_TOKEN} ${CI_REGISTRY} - docker pull $CI_REGISTRY_IMAGE/fpm:$CI_PIPELINE_ID # Push to AWS registry - docker tag $CI_REGISTRY_IMAGE/fpm:$CI_PIPELINE_ID $ECR_REPOSITORY_URL_FPM:$IMAGE_LABEL - docker push $ECR_REPOSITORY_URL_FPM:$IMAGE_LABEL # Push to Gitlab registry - docker tag $CI_REGISTRY_IMAGE/fpm:$CI_PIPELINE_ID $CI_REGISTRY_IMAGE/fpm:$IMAGE_LABEL - docker push $CI_REGISTRY_IMAGE/fpm:$IMAGE_LABEL # Deploy to ECS - aws ecs update-service --service=$ECS_APP_CANARY_SERVICE --force-new-deployment --region us-east-1 --cluster=$ECS_CLUSTER # Update sentry - sentry-cli releases deploys $CI_PIPELINE_ID new -e $IMAGE_LABEL only: refs: - master - test/gitlab-ci environment: name: canary url: https://www.minds.com/?canary=1 # requires canary cookie when: manual allow_failure: false # prevents auto deploy to full production production:fpm: stage: deploy:production image: minds/ci:latest image: minds/ci:latest script: script: - IMAGE_LABEL="production" - $(aws ecr get-login --no-include-email --region us-east-1) - $(aws ecr get-login --no-include-email --region us-east-1) - docker login -u gitlab-ci-token -p ${CI_BUILD_TOKEN} ${CI_REGISTRY} - docker login -u gitlab-ci-token -p ${CI_BUILD_TOKEN} ${CI_REGISTRY} - docker pull $CI_REGISTRY_IMAGE/fpm:$CI_BUILD_REF - docker pull $CI_REGISTRY_IMAGE/fpm:$CI_PIPELINE_ID # Push to production registry # Push to AWS registry - docker tag $CI_REGISTRY_IMAGE/fpm:$CI_BUILD_REF $REPOSITORY_URL_FPM - docker tag $CI_REGISTRY_IMAGE/fpm:$CI_PIPELINE_ID $ECR_REPOSITORY_URL_FPM:$IMAGE_LABEL - docker push $REPOSITORY_URL_FPM - docker push $ECR_REPOSITORY_URL_FPM:$IMAGE_LABEL # Push to gitlab register # Push to Gitlab registry - docker tag $CI_REGISTRY_IMAGE/fpm:$CI_BUILD_REF $CI_REGISTRY_IMAGE/fpm:latest - docker tag $CI_REGISTRY_IMAGE/fpm:$CI_PIPELINE_ID $CI_REGISTRY_IMAGE/fpm:$IMAGE_LABEL - docker push $CI_REGISTRY_IMAGE/fpm:latest - docker push $CI_REGISTRY_IMAGE/fpm:$IMAGE_LABEL - aws ecs update-service --service=$SERVICE_FPM --force-new-deployment --region us-east-1 --cluster=$CLUSTER # Delpoy to ECS - aws ecs update-service --service=$ECS_APP_PRODUCTION_SERVICE --force-new-deployment --region us-east-1 --cluster=$ECS_CLUSTER # Update sentry - sentry-cli releases deploys $CI_PIPELINE_ID new -e $IMAGE_LABEL only: only: refs: refs: - master - master - test/gitlab-ci - test/gitlab-ci environment: environment: name: production name: production url: https://www.minds.com/ when: delayed start_in: 12 hours # reduce? can always be deployed manually earlier too deploy:runners: production:runners: stage: deploy stage: deploy:production image: minds/ci:latest image: minds/ci:latest script: script: - IMAGE_LABEL="production" - $(aws ecr get-login --no-include-email --region us-east-1) - $(aws ecr get-login --no-include-email --region us-east-1) - docker login -u gitlab-ci-token -p ${CI_BUILD_TOKEN} ${CI_REGISTRY} - docker login -u gitlab-ci-token -p ${CI_BUILD_TOKEN} ${CI_REGISTRY} - docker pull $CI_REGISTRY_IMAGE/runners:$CI_BUILD_REF - docker pull $CI_REGISTRY_IMAGE/runners:$CI_PIPELINE_ID # Push to production register # Push to production register - docker tag $CI_REGISTRY_IMAGE/runners:$CI_BUILD_REF $REPOSITORY_URL_RUNNERS - docker tag $CI_REGISTRY_IMAGE/runners:$CI_PIPELINE_ID $ECR_REPOSITORY_URL_RUNNERS:$IMAGE_LABEL - docker push $REPOSITORY_URL_RUNNERS - docker push $ECR_REPOSITORY_URL_RUNNERS:$IMAGE_LABEL # Push gitlab registry # Push gitlab registry - docker tag $CI_REGISTRY_IMAGE/runners:$CI_BUILD_REF $CI_REGISTRY_IMAGE/runners:latest - docker tag $CI_REGISTRY_IMAGE/runners:$CI_PIPELINE_ID $CI_REGISTRY_IMAGE/runners:$IMAGE_LABEL - docker push $CI_REGISTRY_IMAGE/runners:latest - docker push $CI_REGISTRY_IMAGE/runners:$IMAGE_LABEL - aws ecs update-service --service=$SERVICE_RUNNERS --force-new-deployment --region us-east-1 --cluster=$CLUSTER - aws ecs update-service --service=$ECS_RUNNERS_PRODUCTION_SERVICE --force-new-deployment --region us-east-1 --cluster=$ECS_CLUSTER only: only: refs: refs: - master - master - test/gitlab-ci - test/gitlab-ci environment: environment: name: production name: production url: https://www.minds.com/
.php_cs +7 −2 Original line number Original line Diff line number Diff line Loading @@ -5,5 +5,10 @@ $finder = PhpCsFixer\Finder::create() ->in(__DIR__); ->in(__DIR__); return PhpCsFixer\Config::create() return PhpCsFixer\Config::create() ->fixers(['psr2', 'strict_param', 'short_array_syntax', 'no_blank_lines_after_class_opening']) ->setRules([ ->finder($finder); '@PSR2' => true, 'strict_param' => true, 'array_syntax' => ['syntax' => 'short'], 'no_blank_lines_after_class_opening' => true, ]) ->setFinder($finder);
Api/Exportable.php +4 −0 Original line number Original line Diff line number Diff line Loading @@ -118,6 +118,10 @@ class Exportable implements \JsonSerializable $exported['ownerObj']['guid'] = (string) $exported['ownerObj']['guid']; $exported['ownerObj']['guid'] = (string) $exported['ownerObj']['guid']; } } if (isset($exported['urn']) && isset($_SERVER['HTTP_APP_VERSION'])) { $exported['urn'] = "urn:entity:{$exported['guid']}"; } foreach ($this->exceptions as $exception) { foreach ($this->exceptions as $exception) { $exported[$exception] = $item->{$exception}; $exported[$exception] = $item->{$exception}; } } Loading
Api/Factory.php +11 −11 Original line number Original line Diff line number Diff line Loading @@ -50,7 +50,7 @@ class Factory if (!$handler instanceof Interfaces\ApiIgnorePam) { if (!$handler instanceof Interfaces\ApiIgnorePam) { self::pamCheck($request, $response); self::pamCheck($request, $response); } } $pages = array_splice($segments, $loop) ?: array(); $pages = array_splice($segments, $loop) ?: []; return $handler->$method($pages); return $handler->$method($pages); } } } } Loading @@ -65,7 +65,7 @@ class Factory if (!$handler instanceof Interfaces\ApiIgnorePam) { if (!$handler instanceof Interfaces\ApiIgnorePam) { self::pamCheck($request, $response); self::pamCheck($request, $response); } } $pages = array_splice($segments, $loop) ?: array(); $pages = array_splice($segments, $loop) ?: []; return $handler->$method($pages); return $handler->$method($pages); } } --$loop; --$loop; Loading Loading @@ -111,7 +111,7 @@ class Factory header('Content-type: application/json'); header('Content-type: application/json'); header("Access-Control-Allow-Origin: *"); header("Access-Control-Allow-Origin: *"); header('HTTP/1.1 401 Unauthorized', true, 401); header('HTTP/1.1 401 Unauthorized', true, 401); echo json_encode(array('error'=>'You are not an admin', 'code'=>401)); echo json_encode(['error'=>'You are not an admin', 'code'=>401]); exit; exit; } } } } Loading Loading @@ -143,11 +143,11 @@ class Factory * Builds an API response * Builds an API response * @param array $data * @param array $data */ */ public static function response($data = array()) public static function response($data = []) { { $data = array_merge(array( $data = array_merge([ 'status' => 'success', //should success be assumed? 'status' => 'success', //should success be assumed? ), $data); ], $data); ob_end_clean(); ob_end_clean(); Loading @@ -162,7 +162,7 @@ class Factory * @return array - an array of the entities * @return array - an array of the entities * @deprecated * @deprecated */ */ public static function exportable($entities, $exceptions = array(), $exportContext = false) public static function exportable($entities, $exceptions = [], $exportContext = false) { { if (!$entities) { if (!$entities) { return []; return []; Loading
Api/Routes.php +1 −1 Original line number Original line Diff line number Diff line Loading @@ -6,7 +6,7 @@ namespace Minds\Api; */ */ class Routes class Routes { { public static $routes = array(); public static $routes = []; /** /** * Adds a custom API route resolution * Adds a custom API route resolution Loading