Skip to content

Commit

Permalink
Disable public playground environment
Browse files Browse the repository at this point in the history
  • Loading branch information
pdavide committed Jan 28, 2023
1 parent 17deaf2 commit 2a3118f
Show file tree
Hide file tree
Showing 12 changed files with 183 additions and 162 deletions.
193 changes: 98 additions & 95 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,99 +14,102 @@ jobs:
environment: PublicPlayground
runs-on: ubuntu-latest
steps:
- name: Set release image tag
run: echo "RELEASE_TAG=$(echo ${{ github.ref }} | cut -c11-)" >> $GITHUB_ENV
- name: Checkout code
uses: actions/checkout@v2
- name: Prepare files
if: success()
run: cp ${{ github.workspace }}/containers/queue-worker/supervisord.conf ${{ github.workspace }}
- name: Build image
if: success()
run: docker build --no-cache --rm -f ${{ github.workspace }}/Dockerfile.portal --build-arg PHP_VERSION=$PHP_VERSION -t $ORGANIZATION/$IMAGE_NAME:$IMAGE_TAG ${{ github.workspace }}
- name: Apply release tag
if: success()
run: docker tag $ORGANIZATION/$IMAGE_NAME:$IMAGE_TAG $ORGANIZATION/$IMAGE_NAME:$RELEASE_TAG
- name: Push image
if: success()
- name: Workflow disabled
run: |
echo ${{ secrets.DOCKER_HUB_TOKEN }} | docker login --username ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin
docker push $ORGANIZATION/$IMAGE_NAME:$RELEASE_TAG
docker push $ORGANIZATION/$IMAGE_NAME:$IMAGE_TAG
- name: Docker logout
if: always()
run: docker logout
- name: Get portal container index in its deployment
if: success()
run: |
echo "PORTAL_CONTAINER_INDEX=$(curl -k \
--silent \
--cert <(echo "$K8S_CLIENT_CERT") \
--key <(echo "$K8S_CLIENT_KEY") \
-H 'Accept: application/json' \
https://k8s.webanalytics.italia.it/apis/apps/v1/namespaces/wai-stag/deployments/portal \
| jq '.spec.template.spec.containers | map(.name == "portal") | index(true)')" >> $GITHUB_ENV
- name: Trigger portal rolling update in public-playground environment
if: success()
run: |
curl -X PATCH \
--silent \
--output /dev/null \
--cert <(echo "$K8S_CLIENT_CERT") \
--key <(echo "$K8S_CLIENT_KEY") \
-d @- \
-H 'Accept: application/json' \
-H 'Content-Type: application/json-patch+json' \
https://k8s.webanalytics.italia.it/apis/apps/v1/namespaces/wai-play/deployments/portal <<EOF
[
{ "op": "replace", "path": "/spec/template/spec/containers/${{ env.PORTAL_CONTAINER_INDEX }}/image", "value": "$ORGANIZATION/$IMAGE_NAME:$RELEASE_TAG" }
]
EOF
- name: Trigger portal rolling update in public-playground environment (initContainer)
if: success()
run: |
curl -X PATCH \
--silent \
--output /dev/null \
--cert <(echo "$K8S_CLIENT_CERT") \
--key <(echo "$K8S_CLIENT_KEY") \
-d @- \
-H 'Accept: application/json' \
-H 'Content-Type: application/json-patch+json' \
https://k8s.webanalytics.italia.it/apis/apps/v1/namespaces/wai-play/deployments/portal <<EOF
[
{ "op": "replace", "path": "/spec/template/spec/initContainers/0/image", "value": "$ORGANIZATION/$IMAGE_NAME:$RELEASE_TAG" }
]
EOF
- name: Trigger portal-queue-worker rolling update in public-playground environment
if: success()
run: |
curl -X PATCH \
--silent \
--output /dev/null \
--cert <(echo "$K8S_CLIENT_CERT") \
--key <(echo "$K8S_CLIENT_KEY") \
-d @- \
-H 'Accept: application/json' \
-H 'Content-Type: application/json-patch+json' \
https://k8s.webanalytics.italia.it/apis/apps/v1/namespaces/wai-play/deployments/portal-queue-worker <<EOF
[
{ "op": "replace", "path": "/spec/template/spec/containers/0/image", "value": "$ORGANIZATION/$IMAGE_NAME:$RELEASE_TAG" }
]
EOF
- name: Trigger portal-scheduler rolling update in public-playground environment
if: success()
run: |
curl -X PATCH \
--silent \
--output /dev/null \
--cert <(echo "$K8S_CLIENT_CERT") \
--key <(echo "$K8S_CLIENT_KEY") \
-d @- \
-H 'Accept: application/json' \
-H 'Content-Type: application/json-patch+json' \
https://k8s.webanalytics.italia.it/apis/apps/v1/namespaces/wai-play/deployments/portal-scheduler <<EOF
[
{ "op": "replace", "path": "/spec/template/spec/containers/0/image", "value": "$ORGANIZATION/$IMAGE_NAME:$RELEASE_TAG" }
]
EOF
echo "Workflow disabled"
# - name: Set release image tag
# run: echo "RELEASE_TAG=$(echo ${{ github.ref }} | cut -c11-)" >> $GITHUB_ENV
# - name: Checkout code
# uses: actions/checkout@v2
# - name: Prepare files
# if: success()
# run: cp ${{ github.workspace }}/containers/queue-worker/supervisord.conf ${{ github.workspace }}
# - name: Build image
# if: success()
# run: docker build --no-cache --rm -f ${{ github.workspace }}/Dockerfile.portal --build-arg PHP_VERSION=$PHP_VERSION -t $ORGANIZATION/$IMAGE_NAME:$IMAGE_TAG ${{ github.workspace }}
# - name: Apply release tag
# if: success()
# run: docker tag $ORGANIZATION/$IMAGE_NAME:$IMAGE_TAG $ORGANIZATION/$IMAGE_NAME:$RELEASE_TAG
# - name: Push image
# if: success()
# run: |
# echo ${{ secrets.DOCKER_HUB_TOKEN }} | docker login --username ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin
# docker push $ORGANIZATION/$IMAGE_NAME:$RELEASE_TAG
# docker push $ORGANIZATION/$IMAGE_NAME:$IMAGE_TAG
# - name: Docker logout
# if: always()
# run: docker logout
# - name: Get portal container index in its deployment
# if: success()
# run: |
# echo "PORTAL_CONTAINER_INDEX=$(curl -k \
# --silent \
# --cert <(echo "$K8S_CLIENT_CERT") \
# --key <(echo "$K8S_CLIENT_KEY") \
# -H 'Accept: application/json' \
# https://k8s.webanalytics.italia.it/apis/apps/v1/namespaces/wai-stag/deployments/portal \
# | jq '.spec.template.spec.containers | map(.name == "portal") | index(true)')" >> $GITHUB_ENV
# - name: Trigger portal rolling update in public-playground environment
# if: success()
# run: |
# curl -X PATCH \
# --silent \
# --output /dev/null \
# --cert <(echo "$K8S_CLIENT_CERT") \
# --key <(echo "$K8S_CLIENT_KEY") \
# -d @- \
# -H 'Accept: application/json' \
# -H 'Content-Type: application/json-patch+json' \
# https://k8s.webanalytics.italia.it/apis/apps/v1/namespaces/wai-play/deployments/portal <<EOF
# [
# { "op": "replace", "path": "/spec/template/spec/containers/${{ env.PORTAL_CONTAINER_INDEX }}/image", "value": "$ORGANIZATION/$IMAGE_NAME:$RELEASE_TAG" }
# ]
# EOF
# - name: Trigger portal rolling update in public-playground environment (initContainer)
# if: success()
# run: |
# curl -X PATCH \
# --silent \
# --output /dev/null \
# --cert <(echo "$K8S_CLIENT_CERT") \
# --key <(echo "$K8S_CLIENT_KEY") \
# -d @- \
# -H 'Accept: application/json' \
# -H 'Content-Type: application/json-patch+json' \
# https://k8s.webanalytics.italia.it/apis/apps/v1/namespaces/wai-play/deployments/portal <<EOF
# [
# { "op": "replace", "path": "/spec/template/spec/initContainers/0/image", "value": "$ORGANIZATION/$IMAGE_NAME:$RELEASE_TAG" }
# ]
# EOF
# - name: Trigger portal-queue-worker rolling update in public-playground environment
# if: success()
# run: |
# curl -X PATCH \
# --silent \
# --output /dev/null \
# --cert <(echo "$K8S_CLIENT_CERT") \
# --key <(echo "$K8S_CLIENT_KEY") \
# -d @- \
# -H 'Accept: application/json' \
# -H 'Content-Type: application/json-patch+json' \
# https://k8s.webanalytics.italia.it/apis/apps/v1/namespaces/wai-play/deployments/portal-queue-worker <<EOF
# [
# { "op": "replace", "path": "/spec/template/spec/containers/0/image", "value": "$ORGANIZATION/$IMAGE_NAME:$RELEASE_TAG" }
# ]
# EOF
# - name: Trigger portal-scheduler rolling update in public-playground environment
# if: success()
# run: |
# curl -X PATCH \
# --silent \
# --output /dev/null \
# --cert <(echo "$K8S_CLIENT_CERT") \
# --key <(echo "$K8S_CLIENT_KEY") \
# -d @- \
# -H 'Accept: application/json' \
# -H 'Content-Type: application/json-patch+json' \
# https://k8s.webanalytics.italia.it/apis/apps/v1/namespaces/wai-play/deployments/portal-scheduler <<EOF
# [
# { "op": "replace", "path": "/spec/template/spec/containers/0/image", "value": "$ORGANIZATION/$IMAGE_NAME:$RELEASE_TAG" }
# ]
# EOF
1 change: 1 addition & 0 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ protected function schedule(Schedule $schedule): void
// $schedule->job(new MonitorWebsitesTracking())->daily()->onOneServer(); // DisableTracking plugin is currently not working properly
// $schedule->job(new PurgePendingInvitations())->dailyAt('03:30')->onOneServer();
$schedule->job(new UpdateSiteListOnRedis())->hourly()->onOneServer();
// public playground environment disabled
// $publicPlaygroundResetTime = config('wai.reset_public_playground_hour', 23) . ':' . config('wai.reset_public_playground_minute', 30);
// $schedule->job(new ResetEnvironment())->weekly()->days(config('wai.reset_public_playground_day', 0))->at($publicPlaygroundResetTime)->onOneServer()->environments(['public-playground']);
$schedule->job(new PurgeOrphanedEntities())->hourly()->onOneServer();
Expand Down
50 changes: 27 additions & 23 deletions app/Providers/ViewServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,32 +54,36 @@ public function boot()
View::composer('layouts.includes.head', MetadataComposer::class);
View::composer('layouts.includes.modal', ModalComposer::class);
View::composer('layouts.includes.notification', NotificationComposer::class);
// Note: public playground environment disabled
View::composer('layouts.includes.highlight_bar', function ($view) {
$hasResetCountdown = 'public-playground' === config('app.env');
$view->with('hasResetCountdown', $hasResetCountdown);
if ($hasResetCountdown) {
$nextDayResetPublicPlayground = 'next ' . config('wai.reset_public_playground_day_verbose', 'sunday');
$view->with('hasResetCountdown', false);
});
// View::composer('layouts.includes.highlight_bar', function ($view) {
// $hasResetCountdown = 'public-playground' === config('app.env');
// $view->with('hasResetCountdown', $hasResetCountdown);
// if ($hasResetCountdown) {
// $nextDayResetPublicPlayground = 'next ' . config('wai.reset_public_playground_day_verbose', 'sunday');

try {
$parsedNextDayReset = Carbon::parse($nextDayResetPublicPlayground);
} catch (InvalidFormatException $ife) {
$parsedNextDayReset = Carbon::parse('next sunday');
}
// try {
// $parsedNextDayReset = Carbon::parse($nextDayResetPublicPlayground);
// } catch (InvalidFormatException $ife) {
// $parsedNextDayReset = Carbon::parse('next sunday');
// }

$view->with('countdown', $parsedNextDayReset->setHour(config('wai.reset_public_playground_hour', 23))->setMinutes(config('wai.reset_public_playground_minute', 30))
->diffForHumans(
Carbon::now(),
[
'syntax' => CarbonInterface::DIFF_ABSOLUTE,
'options' => Carbon::JUST_NOW | Carbon::ONE_DAY_WORDS | Carbon::TWO_DAY_WORDS,
'parts' => 2,
'join' => true,
'aUnit' => true,
]
)
);
}
});
// $view->with('countdown', $parsedNextDayReset->setHour(config('wai.reset_public_playground_hour', 23))->setMinutes(config('wai.reset_public_playground_minute', 30))
// ->diffForHumans(
// Carbon::now(),
// [
// 'syntax' => CarbonInterface::DIFF_ABSOLUTE,
// 'options' => Carbon::JUST_NOW | Carbon::ONE_DAY_WORDS | Carbon::TWO_DAY_WORDS,
// 'parts' => 2,
// 'join' => true,
// 'aUnit' => true,
// ]
// )
// );
// }
// });
View::composer('*', function ($view) {
$authUser = auth()->user();
$view->with('authUser', $authUser);
Expand Down
2 changes: 2 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@
<token key="APP_SUPER_ADMIN_FISCAL_NUMBER" value="${APP_SUPER_ADMIN_FISCAL_NUMBER}" />
<token key="APP_SUPER_ADMIN_EMAIL" value="${APP_SUPER_ADMIN_EMAIL}" />
<token key="APP_SUPER_ADMIN_PASSWORD" value="${APP_SUPER_ADMIN_PASSWORD}" />
<!-- Note: public playground environment disabled
<token key="RESET_PUBLIC_PLAYGROUND_DAY_VERBOSE" value="${RESET_PUBLIC_PLAYGROUND_DAY_VERBOSE}" />
<token key="RESET_PUBLIC_PLAYGROUND_DAY" value="${RESET_PUBLIC_PLAYGROUND_DAY}" />
<token key="RESET_PUBLIC_PLAYGROUND_HOUR" value="${RESET_PUBLIC_PLAYGROUND_HOUR}" />
<token key="RESET_PUBLIC_PLAYGROUND_MINUTE" value="${RESET_PUBLIC_PLAYGROUND_MINUTE}" />
-->
<token key="CLOSED_BETA_WHITELIST_WEBHOOK_CLIENT_SECRET" value="${CLOSED_BETA_WHITELIST_WEBHOOK_CLIENT_SECRET}" />
<token key="CLOSED_BETA_WHITELIST_REPOSITORY_FULL_NAME" value="${CLOSED_BETA_WHITELIST_REPOSITORY_FULL_NAME}" />
<token key="CLOSED_BETA_WHITELIST_REPOSITORY_BRANCH" value="${CLOSED_BETA_WHITELIST_REPOSITORY_BRANCH}" />
Expand Down
9 changes: 5 additions & 4 deletions config/wai.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,9 @@
| Day: sundays = 0, mondays = 1, tuesdays = 2, wednesdays = 3, thursdays = 4, fridays = 5, saturdays = 6
*/

'reset_public_playground_day_verbose' => env('RESET_PUBLIC_PLAYGROUND_DAY_VERBOSE', 'sunday'),
'reset_public_playground_day' => env('RESET_PUBLIC_PLAYGROUND_DAY', 0),
'reset_public_playground_hour' => env('RESET_PUBLIC_PLAYGROUND_HOUR', 23),
'reset_public_playground_minute' => env('RESET_PUBLIC_PLAYGROUND_MINUTE', 30),
// Note: public playground environment disabled
// 'reset_public_playground_day_verbose' => env('RESET_PUBLIC_PLAYGROUND_DAY_VERBOSE', 'sunday'),
// 'reset_public_playground_day' => env('RESET_PUBLIC_PLAYGROUND_DAY', 0),
// 'reset_public_playground_hour' => env('RESET_PUBLIC_PLAYGROUND_HOUR', 23),
// 'reset_public_playground_minute' => env('RESET_PUBLIC_PLAYGROUND_MINUTE', 30),
];
12 changes: 6 additions & 6 deletions env/build.properties.example
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ APP_SUSPENDED=false
APP_CUSTOM_PUBLIC_ADMINISTRATIONS_ENABLED=false
APP_API_VERSION=v1

# Reset public playground
# Reset public playground (public playground environment disabled)
# Value must be between 0 = Sunday and 6 = Saturday
# -----------
RESET_PUBLIC_PLAYGROUND_DAY_VERBOSE=sunday
RESET_PUBLIC_PLAYGROUND_DAY=0
RESET_PUBLIC_PLAYGROUND_HOUR=23
RESET_PUBLIC_PLAYGROUND_MINUTE=30
#RESET_PUBLIC_PLAYGROUND_DAY_VERBOSE=sunday
#RESET_PUBLIC_PLAYGROUND_DAY=0
#RESET_PUBLIC_PLAYGROUND_HOUR=23
#RESET_PUBLIC_PLAYGROUND_MINUTE=30

# Closed beta repository
# ----------------------
Expand Down Expand Up @@ -223,7 +223,7 @@ MATOMO_PUBLIC_USER_APIKEY=540e13e315b7c8bbf374a0ff227a1ae1
MATOMO_VERSION=3.14.1

# Matomo WAI theme version
MATOMO_WAI_THEME_VERSION=1.3.1-beta
MATOMO_WAI_THEME_VERSION=1.3.2-beta

# Matomo plugins versions
MATOMO_PLUGIN_DISABLESITETRACKING_VERSION=v1.2.0
Expand Down
12 changes: 6 additions & 6 deletions env/build.properties.testing
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ APP_SUSPENDED=false
APP_CUSTOM_PUBLIC_ADMINISTRATIONS_ENABLED=true
APP_API_VERSION=v1

# Reset public playground
# Reset public playground (public playground environment disabled)
# Value must be between 0 = Sunday and 6 = Saturday
# -----------
RESET_PUBLIC_PLAYGROUND_DAY_VERBOSE=sunday
RESET_PUBLIC_PLAYGROUND_DAY=0
RESET_PUBLIC_PLAYGROUND_HOUR=23
RESET_PUBLIC_PLAYGROUND_MINUTE=30
#RESET_PUBLIC_PLAYGROUND_DAY_VERBOSE=sunday
#RESET_PUBLIC_PLAYGROUND_DAY=0
#RESET_PUBLIC_PLAYGROUND_HOUR=23
#RESET_PUBLIC_PLAYGROUND_MINUTE=30

# Closed beta repository
# ----------------------
Expand Down Expand Up @@ -222,7 +222,7 @@ MATOMO_PUBLIC_USER_APIKEY=d300edfad46f2723f0df5b5b5877033b
MATOMO_VERSION=3.14.1

# Matomo WAI theme version
MATOMO_WAI_THEME_VERSION=1.3.1-beta
MATOMO_WAI_THEME_VERSION=1.3.2-beta

# Matomo plugins versions
MATOMO_PLUGIN_DISABLESITETRACKING_VERSION=v1.2.0
Expand Down
9 changes: 5 additions & 4 deletions env/env-laravel.template
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ APP_CUSTOM_PUBLIC_ADMINISTRATIONS_ENABLED=@APP_CUSTOM_PUBLIC_ADMINISTRATIONS_ENA
APP_URL=https://@HOSTNAME@
APP_API_VERSION=@APP_API_VERSION@

RESET_PUBLIC_PLAYGROUND_DAY_VERBOSE=@RESET_PUBLIC_PLAYGROUND_DAY_VERBOSE@
RESET_PUBLIC_PLAYGROUND_DAY=@RESET_PUBLIC_PLAYGROUND_DAY@
RESET_PUBLIC_PLAYGROUND_HOUR=@RESET_PUBLIC_PLAYGROUND_HOUR@
RESET_PUBLIC_PLAYGROUND_MINUTE=@RESET_PUBLIC_PLAYGROUND_MINUTE@
# Note: public playground environment disabled
#RESET_PUBLIC_PLAYGROUND_DAY_VERBOSE=@RESET_PUBLIC_PLAYGROUND_DAY_VERBOSE@
#RESET_PUBLIC_PLAYGROUND_DAY=@RESET_PUBLIC_PLAYGROUND_DAY@
#RESET_PUBLIC_PLAYGROUND_HOUR=@RESET_PUBLIC_PLAYGROUND_HOUR@
#RESET_PUBLIC_PLAYGROUND_MINUTE=@RESET_PUBLIC_PLAYGROUND_MINUTE@

APP_SUPER_ADMIN_NAME=@APP_SUPER_ADMIN_NAME@
APP_SUPER_ADMIN_FAMILY_NAME=@APP_SUPER_ADMIN_FAMILY_NAME@
Expand Down
9 changes: 5 additions & 4 deletions resources/data/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ it:
logo_raster: /images/wai-logo.png
pill: beta
highlight:
public-playground: |
Questo è l'ambiente **public playground**. Ogni settimana il sistema
viene automaticamente resettato. [Maggiori
informazioni](https://play.webanalytics.italia.it/faq#public-playground).
# Note: public playground environment disabled
# public-playground: |
# Questo è l'ambiente **public playground**. Ogni settimana il sistema
# viene automaticamente resettato. [Maggiori
# informazioni](https://play.webanalytics.italia.it/faq#public-playground).
staging: |
Questo è l'ambiente di **staging**. L'istanza potrebbe essere resettata
senza preavviso.
Expand Down
Loading

0 comments on commit 2a3118f

Please sign in to comment.