From 6a61993824c24d7dc2d46651639b3fe167aab524 Mon Sep 17 00:00:00 2001 From: Stijn van der Vegt Date: Mon, 21 Dec 2020 14:13:01 +0100 Subject: [PATCH 01/41] make git username and email configurable in bash file --- .travis.yml | 3 +++ gitops_push | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 164ee6db5..f239d1101 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,6 +21,9 @@ env: - GITOPS_ACC_VALUES_FILE=${GITOPS_ACC_VALUES_FILE:-k8s/openstad/environments/acc.values.yaml} - GITOPS_PROD_VALUES_FILE=${GITOPS_PROD_VALUES_FILE:-k8s/openstad/environments/prod.values.yaml} + - GIT_USER_EMAIL="travis@travis-ci.org" + - GIT_USER_NAME="Travis CI" + # Kube deploy variables - K8S_DEPLOYMENT_NAME=openstad-frontend - K8S_NAMESPACE=openstad diff --git a/gitops_push b/gitops_push index 1711ef4cd..76242404f 100644 --- a/gitops_push +++ b/gitops_push @@ -6,8 +6,8 @@ echo "DOCKER PUSH TAG" echo ${IMAGE_TAG} docker push ${IMAGE_TAG} -git config --global user.email "travis@travis-ci.org" -git config --global user.name "Travis CI" +git config --global user.email ${GIT_USER_EMAIL} +git config --global user.name ${GIT_USER_NAME} git clone ${HELM_REPO} && cd ${HELM_REPO_NAME} && \ From b57d196c8ffeb541be11bec52ccae69aaa80db72 Mon Sep 17 00:00:00 2001 From: Stijn van der Vegt Date: Wed, 23 Dec 2020 16:35:51 +0100 Subject: [PATCH 02/41] validate COOKIE_MAX_AGE and parse always to int --- packages/cms/config/siteConfig.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cms/config/siteConfig.js b/packages/cms/config/siteConfig.js index 889704abd..d85c2d651 100644 --- a/packages/cms/config/siteConfig.js +++ b/packages/cms/config/siteConfig.js @@ -59,7 +59,7 @@ module.exports = { httpOnly: true, secure: process.env.COOKIE_SECURE_OFF === 'yes' ? false : true, // Default login lifetime between requests is one day - maxAge: process.env.COOKIE_MAX_AGE || 86400000 + maxAge: parseInt(process.env.COOKIE_MAX_AGE) && ! isNaN(parseInt(process.env.COOKIE_MAX_AGE)) ? parseInt(process.env.COOKIE_MAX_AGE) : 86400000 } }, csrf: { From 54288741742432657392b683d7be94606c92f6e6 Mon Sep 17 00:00:00 2001 From: Stijn van der Vegt Date: Thu, 21 Jan 2021 21:57:34 +0100 Subject: [PATCH 03/41] add github workflow --- .build.sh | 9 +++++++ .github/workflow/gitops-dev.yml | 42 +++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 .build.sh create mode 100644 .github/workflow/gitops-dev.yml diff --git a/.build.sh b/.build.sh new file mode 100644 index 000000000..cb138cb12 --- /dev/null +++ b/.build.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +sleep 15 +mongo default --eval 'db.createUser({user:"ci",pwd:"test",roles:["readWrite"]});' +npm install --production +npm run test -- --coverage +mkdir assets +NODE_ENV=production APOS_MINIFY=1 APOS_WORKFLOW=ON APOS_BUNDLE=assets node apostrophe.js apostrophe:generation --create-bundle assets +docker build -t ${IMAGE_TAG} . diff --git a/.github/workflow/gitops-dev.yml b/.github/workflow/gitops-dev.yml new file mode 100644 index 000000000..d1882c8cc --- /dev/null +++ b/.github/workflow/gitops-dev.yml @@ -0,0 +1,42 @@ +name: GitopsDev + +# Run this workflow every time a new commit pushed to your repository +on: + push: + branches: + - development + - feature/* + +jobs: + gitops: + env: + HELM_REPO_NAME: openstad-kubernetes + HELM_CHART_FOLDER: k8s/openstad + GIT_USER_EMAIL: github@ci.push + GIT_USER_NAME: ci + name: gitops commit + runs-on: ubuntu-latest + + services: + - docker + - mongodb + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Install yq + run: snap install yq --channel=v3/stable + + - name: Run build script + run: ./build.sh + shell: bash + env: + - IMAGE_TAG=${DOCKER_PUBLIC_USERNAME}/${DOCKER_IMAGE_NAME}:${GITHUB_SHA} + + - name: Run docker push script + run: ./gitops_push + shell: bash + env: + - IMAGE_TAG=${DOCKER_PUBLIC_USERNAME}/${DOCKER_IMAGE_NAME}:${GITHUB_SHA} + - GITOPS_VALUES_FILE=k8s/openstad/environments/dev.values.yaml From d3cfe23cbe2eedc8c3d415c0678d0b3dde993e07 Mon Sep 17 00:00:00 2001 From: Stijn van der Vegt Date: Thu, 21 Jan 2021 21:59:50 +0100 Subject: [PATCH 04/41] rename workflows folder --- .github/{workflow => workflows}/gitops-dev.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/{workflow => workflows}/gitops-dev.yml (100%) diff --git a/.github/workflow/gitops-dev.yml b/.github/workflows/gitops-dev.yml similarity index 100% rename from .github/workflow/gitops-dev.yml rename to .github/workflows/gitops-dev.yml From a8b2ee42b3add9531728ec2ac3b2a9e0f5ee32db Mon Sep 17 00:00:00 2001 From: Stijn van der Vegt Date: Thu, 21 Jan 2021 22:01:40 +0100 Subject: [PATCH 05/41] fix env vars --- .github/workflows/gitops-dev.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/gitops-dev.yml b/.github/workflows/gitops-dev.yml index d1882c8cc..4975111b3 100644 --- a/.github/workflows/gitops-dev.yml +++ b/.github/workflows/gitops-dev.yml @@ -32,11 +32,10 @@ jobs: run: ./build.sh shell: bash env: - - IMAGE_TAG=${DOCKER_PUBLIC_USERNAME}/${DOCKER_IMAGE_NAME}:${GITHUB_SHA} - + IMAGE_TAG: ${DOCKER_PUBLIC_USERNAME}/${DOCKER_IMAGE_NAME}:${GITHUB_SHA} - name: Run docker push script run: ./gitops_push shell: bash env: - - IMAGE_TAG=${DOCKER_PUBLIC_USERNAME}/${DOCKER_IMAGE_NAME}:${GITHUB_SHA} - - GITOPS_VALUES_FILE=k8s/openstad/environments/dev.values.yaml + IMAGE_TAG: ${DOCKER_PUBLIC_USERNAME}/${DOCKER_IMAGE_NAME}:${GITHUB_SHA} + GITOPS_VALUES_FILE: k8s/openstad/environments/dev.values.yaml From 301c3b822b8b6c77a61f137241f14a39fe999b5d Mon Sep 17 00:00:00 2001 From: Stijn van der Vegt Date: Thu, 21 Jan 2021 22:06:06 +0100 Subject: [PATCH 06/41] fix services --- .github/workflows/gitops-dev.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/gitops-dev.yml b/.github/workflows/gitops-dev.yml index 4975111b3..c1511401b 100644 --- a/.github/workflows/gitops-dev.yml +++ b/.github/workflows/gitops-dev.yml @@ -18,8 +18,12 @@ jobs: runs-on: ubuntu-latest services: - - docker - - mongodb + docker: + image: docker + mongodb: + image: mongo:3.4.23 + ports: + - 27017:27017 steps: - name: Checkout code From 27e3dada4fef30298f605e1a0cb3821551dfd956 Mon Sep 17 00:00:00 2001 From: Stijn van der Vegt Date: Thu, 21 Jan 2021 22:08:06 +0100 Subject: [PATCH 07/41] use sudo --- .github/workflows/gitops-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gitops-dev.yml b/.github/workflows/gitops-dev.yml index c1511401b..8447ae5d1 100644 --- a/.github/workflows/gitops-dev.yml +++ b/.github/workflows/gitops-dev.yml @@ -30,7 +30,7 @@ jobs: uses: actions/checkout@v2 - name: Install yq - run: snap install yq --channel=v3/stable + run: sudo snap install yq --channel=v3/stable - name: Run build script run: ./build.sh From 997ce7e416ad0198bd70dfceedd6f17f86e61157 Mon Sep 17 00:00:00 2001 From: Stijn van der Vegt Date: Thu, 21 Jan 2021 22:11:45 +0100 Subject: [PATCH 08/41] remove . in build file name --- .build.sh => build.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .build.sh => build.sh (100%) diff --git a/.build.sh b/build.sh similarity index 100% rename from .build.sh rename to build.sh From 05572e5c9cc048e296e70b81cf314468a915bc31 Mon Sep 17 00:00:00 2001 From: Stijn van der Vegt Date: Thu, 21 Jan 2021 22:17:29 +0100 Subject: [PATCH 09/41] chmod build --- .github/workflows/gitops-dev.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/gitops-dev.yml b/.github/workflows/gitops-dev.yml index 8447ae5d1..c891286f6 100644 --- a/.github/workflows/gitops-dev.yml +++ b/.github/workflows/gitops-dev.yml @@ -33,7 +33,9 @@ jobs: run: sudo snap install yq --channel=v3/stable - name: Run build script - run: ./build.sh + run: | + sudo chmod a+x ./build.sh + ./build.sh shell: bash env: IMAGE_TAG: ${DOCKER_PUBLIC_USERNAME}/${DOCKER_IMAGE_NAME}:${GITHUB_SHA} From 86f7305e71467cd240e2a9e4c7d4a2f5d68d96f3 Mon Sep 17 00:00:00 2001 From: Stijn van der Vegt Date: Thu, 21 Jan 2021 22:18:47 +0100 Subject: [PATCH 10/41] also chmod gitops file --- .github/workflows/gitops-dev.yml | 4 +++- build.sh | 0 2 files changed, 3 insertions(+), 1 deletion(-) mode change 100644 => 100755 build.sh diff --git a/.github/workflows/gitops-dev.yml b/.github/workflows/gitops-dev.yml index c891286f6..e8c03891e 100644 --- a/.github/workflows/gitops-dev.yml +++ b/.github/workflows/gitops-dev.yml @@ -40,7 +40,9 @@ jobs: env: IMAGE_TAG: ${DOCKER_PUBLIC_USERNAME}/${DOCKER_IMAGE_NAME}:${GITHUB_SHA} - name: Run docker push script - run: ./gitops_push + run: | + sudo chmod a+x ./gitops_push + ./gitops_push shell: bash env: IMAGE_TAG: ${DOCKER_PUBLIC_USERNAME}/${DOCKER_IMAGE_NAME}:${GITHUB_SHA} diff --git a/build.sh b/build.sh old mode 100644 new mode 100755 From 1a3dcf2fd9de07965e9ece5bc16d4470dd9c4e6e Mon Sep 17 00:00:00 2001 From: Rudi van Hierden Date: Fri, 22 Jan 2021 08:50:34 +0100 Subject: [PATCH 11/41] Use secrets instead of env vars --- .github/workflows/gitops-dev.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/gitops-dev.yml b/.github/workflows/gitops-dev.yml index e8c03891e..6fb0e1c35 100644 --- a/.github/workflows/gitops-dev.yml +++ b/.github/workflows/gitops-dev.yml @@ -38,12 +38,12 @@ jobs: ./build.sh shell: bash env: - IMAGE_TAG: ${DOCKER_PUBLIC_USERNAME}/${DOCKER_IMAGE_NAME}:${GITHUB_SHA} + IMAGE_TAG: ${{ secrets.DOCKER_PUBLIC_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:${GITHUB_SHA} - name: Run docker push script run: | sudo chmod a+x ./gitops_push ./gitops_push shell: bash env: - IMAGE_TAG: ${DOCKER_PUBLIC_USERNAME}/${DOCKER_IMAGE_NAME}:${GITHUB_SHA} + IMAGE_TAG: ${{ secrets.DOCKER_PUBLIC_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:${GITHUB_SHA} GITOPS_VALUES_FILE: k8s/openstad/environments/dev.values.yaml From 60b05f163f5e9a7ce392f46880326749bed7ba71 Mon Sep 17 00:00:00 2001 From: Rudi van Hierden Date: Fri, 22 Jan 2021 08:55:36 +0100 Subject: [PATCH 12/41] Add correct environment --- .github/workflows/gitops-dev.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/gitops-dev.yml b/.github/workflows/gitops-dev.yml index 6fb0e1c35..ad29bd1f9 100644 --- a/.github/workflows/gitops-dev.yml +++ b/.github/workflows/gitops-dev.yml @@ -9,6 +9,7 @@ on: jobs: gitops: + environment: gitops_dev env: HELM_REPO_NAME: openstad-kubernetes HELM_CHART_FOLDER: k8s/openstad From f9460ddba17a9e5349787adf815615aba8c753ae Mon Sep 17 00:00:00 2001 From: Stijn van der Vegt Date: Fri, 22 Jan 2021 08:58:23 +0100 Subject: [PATCH 13/41] use secrets for env vars --- .github/workflows/gitops-dev.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/gitops-dev.yml b/.github/workflows/gitops-dev.yml index e8c03891e..67af89b20 100644 --- a/.github/workflows/gitops-dev.yml +++ b/.github/workflows/gitops-dev.yml @@ -13,7 +13,12 @@ jobs: HELM_REPO_NAME: openstad-kubernetes HELM_CHART_FOLDER: k8s/openstad GIT_USER_EMAIL: github@ci.push - GIT_USER_NAME: ci + GIT_USER_NAME: ${{ secrets.GIT_USER_NAME }} + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + HELM_REPO_WITH_TOKEN: ${{ secrets.HELM_REPO_WITH_TOKEN }} + GITOPS_RELEASE_BRANCH: ${{ secrets.GITOPS_RELEASE_BRANCH }} + name: gitops commit runs-on: ubuntu-latest @@ -38,12 +43,12 @@ jobs: ./build.sh shell: bash env: - IMAGE_TAG: ${DOCKER_PUBLIC_USERNAME}/${DOCKER_IMAGE_NAME}:${GITHUB_SHA} + IMAGE_TAG: ${{ secrets.DOCKER_PUBLIC_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:${{ secrets.GITHUB_SHA }} - name: Run docker push script run: | sudo chmod a+x ./gitops_push ./gitops_push shell: bash env: - IMAGE_TAG: ${DOCKER_PUBLIC_USERNAME}/${DOCKER_IMAGE_NAME}:${GITHUB_SHA} + IMAGE_TAG: ${{ secrets.DOCKER_PUBLIC_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:${{ secrets.GITHUB_SHA }} GITOPS_VALUES_FILE: k8s/openstad/environments/dev.values.yaml From 2065a82cfc78d074a065052977473389b160b186 Mon Sep 17 00:00:00 2001 From: Rudi van Hierden Date: Fri, 22 Jan 2021 08:59:56 +0100 Subject: [PATCH 14/41] Use github sha --- .github/workflows/gitops-dev.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/gitops-dev.yml b/.github/workflows/gitops-dev.yml index ad29bd1f9..4e2e5b0dc 100644 --- a/.github/workflows/gitops-dev.yml +++ b/.github/workflows/gitops-dev.yml @@ -39,12 +39,12 @@ jobs: ./build.sh shell: bash env: - IMAGE_TAG: ${{ secrets.DOCKER_PUBLIC_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:${GITHUB_SHA} + IMAGE_TAG: ${{ secrets.DOCKER_PUBLIC_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:${{ github.sha }} - name: Run docker push script run: | sudo chmod a+x ./gitops_push ./gitops_push shell: bash env: - IMAGE_TAG: ${{ secrets.DOCKER_PUBLIC_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:${GITHUB_SHA} + IMAGE_TAG: ${{ secrets.DOCKER_PUBLIC_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:${{ github.sha }} GITOPS_VALUES_FILE: k8s/openstad/environments/dev.values.yaml From 313bdaef45c6da513acf86deb1a54970dd0c028a Mon Sep 17 00:00:00 2001 From: Rudi van Hierden Date: Fri, 22 Jan 2021 09:43:46 +0100 Subject: [PATCH 15/41] Add HELM_REPO env var --- .github/workflows/gitops-dev.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/gitops-dev.yml b/.github/workflows/gitops-dev.yml index b497d96ea..d7d83b668 100644 --- a/.github/workflows/gitops-dev.yml +++ b/.github/workflows/gitops-dev.yml @@ -17,6 +17,7 @@ jobs: GIT_USER_NAME: ${{ secrets.GIT_USER_NAME }} DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + HELM_REPO: ${{ secrets.HELM_REPO }} HELM_REPO_WITH_TOKEN: ${{ secrets.HELM_REPO_WITH_TOKEN }} GITOPS_RELEASE_BRANCH: ${{ secrets.GITOPS_RELEASE_BRANCH }} From 1d2e82ca5692997441e1956ae4065d2bee802183 Mon Sep 17 00:00:00 2001 From: Rudi van Hierden Date: Fri, 22 Jan 2021 10:06:45 +0100 Subject: [PATCH 16/41] Set short SHA --- .github/workflows/gitops-dev.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/gitops-dev.yml b/.github/workflows/gitops-dev.yml index d7d83b668..9eed7cc4e 100644 --- a/.github/workflows/gitops-dev.yml +++ b/.github/workflows/gitops-dev.yml @@ -20,6 +20,7 @@ jobs: HELM_REPO: ${{ secrets.HELM_REPO }} HELM_REPO_WITH_TOKEN: ${{ secrets.HELM_REPO_WITH_TOKEN }} GITOPS_RELEASE_BRANCH: ${{ secrets.GITOPS_RELEASE_BRANCH }} + SHORT_SHA: ${{ github.sha }} name: gitops commit runs-on: ubuntu-latest @@ -39,18 +40,24 @@ jobs: - name: Install yq run: sudo snap install yq --channel=v3/stable + - name: Set short SHA (8 characters) + shell: bash + run: | + SHORT_SHA=$(echo $GITHUB_SHA | cut -c 1-8) + echo "SHORT_SHA is now '$SHORT_SHA', was '$GITHUB_SHA'" + - name: Run build script run: | sudo chmod a+x ./build.sh ./build.sh shell: bash env: - IMAGE_TAG: ${{ secrets.DOCKER_PUBLIC_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:${{ github.sha }} + IMAGE_TAG: ${{ secrets.DOCKER_PUBLIC_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:$SHORT_SHA - name: Run docker push script run: | sudo chmod a+x ./gitops_push ./gitops_push shell: bash env: - IMAGE_TAG: ${{ secrets.DOCKER_PUBLIC_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:${{ github.sha }} + IMAGE_TAG: ${{ secrets.DOCKER_PUBLIC_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:$SHORT_SHA GITOPS_VALUES_FILE: k8s/openstad/environments/dev.values.yaml From c405d3bb5bc03f607e6bfd4a39615c36aba76674 Mon Sep 17 00:00:00 2001 From: Rudi van Hierden Date: Fri, 22 Jan 2021 10:09:11 +0100 Subject: [PATCH 17/41] Add quotes around GIT_USER_NAME --- .github/workflows/gitops-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gitops-dev.yml b/.github/workflows/gitops-dev.yml index 9eed7cc4e..bdd3bcbc7 100644 --- a/.github/workflows/gitops-dev.yml +++ b/.github/workflows/gitops-dev.yml @@ -14,7 +14,7 @@ jobs: HELM_REPO_NAME: openstad-kubernetes HELM_CHART_FOLDER: k8s/openstad GIT_USER_EMAIL: github@ci.push - GIT_USER_NAME: ${{ secrets.GIT_USER_NAME }} + GIT_USER_NAME: "${{ secrets.GIT_USER_NAME }}" DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} HELM_REPO: ${{ secrets.HELM_REPO }} From aa000f1b4d4e735a74706c5ccbd7a873a66aa1f8 Mon Sep 17 00:00:00 2001 From: Rudi van Hierden Date: Fri, 22 Jan 2021 10:15:26 +0100 Subject: [PATCH 18/41] Set short sha in env --- .github/workflows/gitops-dev.yml | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/.github/workflows/gitops-dev.yml b/.github/workflows/gitops-dev.yml index bdd3bcbc7..43cab01af 100644 --- a/.github/workflows/gitops-dev.yml +++ b/.github/workflows/gitops-dev.yml @@ -20,7 +20,7 @@ jobs: HELM_REPO: ${{ secrets.HELM_REPO }} HELM_REPO_WITH_TOKEN: ${{ secrets.HELM_REPO_WITH_TOKEN }} GITOPS_RELEASE_BRANCH: ${{ secrets.GITOPS_RELEASE_BRANCH }} - SHORT_SHA: ${{ github.sha }} + SHORT_SHA: $(echo ${{ git.sha }} | cut -c 1-8) name: gitops commit runs-on: ubuntu-latest @@ -40,24 +40,18 @@ jobs: - name: Install yq run: sudo snap install yq --channel=v3/stable - - name: Set short SHA (8 characters) - shell: bash - run: | - SHORT_SHA=$(echo $GITHUB_SHA | cut -c 1-8) - echo "SHORT_SHA is now '$SHORT_SHA', was '$GITHUB_SHA'" - - name: Run build script run: | sudo chmod a+x ./build.sh ./build.sh shell: bash env: - IMAGE_TAG: ${{ secrets.DOCKER_PUBLIC_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:$SHORT_SHA + IMAGE_TAG: ${{ secrets.DOCKER_PUBLIC_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:${{ env.SHORT_SHA }} - name: Run docker push script run: | sudo chmod a+x ./gitops_push ./gitops_push shell: bash env: - IMAGE_TAG: ${{ secrets.DOCKER_PUBLIC_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:$SHORT_SHA + IMAGE_TAG: ${{ secrets.DOCKER_PUBLIC_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:${{ env.SHORT_SHA }} GITOPS_VALUES_FILE: k8s/openstad/environments/dev.values.yaml From db63ed8401acab96366ab7b60ea7d96654032014 Mon Sep 17 00:00:00 2001 From: Rudi van Hierden Date: Fri, 22 Jan 2021 10:17:47 +0100 Subject: [PATCH 19/41] Change `git` to `github` --- .github/workflows/gitops-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gitops-dev.yml b/.github/workflows/gitops-dev.yml index 43cab01af..c68b6f2c3 100644 --- a/.github/workflows/gitops-dev.yml +++ b/.github/workflows/gitops-dev.yml @@ -20,7 +20,7 @@ jobs: HELM_REPO: ${{ secrets.HELM_REPO }} HELM_REPO_WITH_TOKEN: ${{ secrets.HELM_REPO_WITH_TOKEN }} GITOPS_RELEASE_BRANCH: ${{ secrets.GITOPS_RELEASE_BRANCH }} - SHORT_SHA: $(echo ${{ git.sha }} | cut -c 1-8) + SHORT_SHA: $(echo ${{ github.sha }} | cut -c 1-8) name: gitops commit runs-on: ubuntu-latest From fde0cc442e40611d46681ff449bf4fecf7f9df1f Mon Sep 17 00:00:00 2001 From: Rudi van Hierden Date: Fri, 22 Jan 2021 10:25:56 +0100 Subject: [PATCH 20/41] Set sha_short as vars output --- .github/workflows/gitops-dev.yml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/gitops-dev.yml b/.github/workflows/gitops-dev.yml index c68b6f2c3..a2f417434 100644 --- a/.github/workflows/gitops-dev.yml +++ b/.github/workflows/gitops-dev.yml @@ -20,7 +20,6 @@ jobs: HELM_REPO: ${{ secrets.HELM_REPO }} HELM_REPO_WITH_TOKEN: ${{ secrets.HELM_REPO_WITH_TOKEN }} GITOPS_RELEASE_BRANCH: ${{ secrets.GITOPS_RELEASE_BRANCH }} - SHORT_SHA: $(echo ${{ github.sha }} | cut -c 1-8) name: gitops commit runs-on: ubuntu-latest @@ -40,18 +39,26 @@ jobs: - name: Install yq run: sudo snap install yq --channel=v3/stable + - name: Set outputs + id: vars + run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" + + - name: Check outputs + run: echo ${{ steps.vars.outputs.sha_short }} + - name: Run build script run: | sudo chmod a+x ./build.sh ./build.sh shell: bash env: - IMAGE_TAG: ${{ secrets.DOCKER_PUBLIC_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:${{ env.SHORT_SHA }} + IMAGE_TAG: ${{ secrets.DOCKER_PUBLIC_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:${{ steps.vars.outputs.sha_short }} + - name: Run docker push script run: | sudo chmod a+x ./gitops_push ./gitops_push shell: bash env: - IMAGE_TAG: ${{ secrets.DOCKER_PUBLIC_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:${{ env.SHORT_SHA }} + IMAGE_TAG: ${{ secrets.DOCKER_PUBLIC_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:${{ steps.vars.outputs.sha_short }} GITOPS_VALUES_FILE: k8s/openstad/environments/dev.values.yaml From 166af09defbe096f783a4764ce094b32152b42f8 Mon Sep 17 00:00:00 2001 From: Rudi van Hierden Date: Fri, 22 Jan 2021 10:47:07 +0100 Subject: [PATCH 21/41] Set git user name in yaml --- .github/workflows/gitops-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gitops-dev.yml b/.github/workflows/gitops-dev.yml index a2f417434..44695b6c5 100644 --- a/.github/workflows/gitops-dev.yml +++ b/.github/workflows/gitops-dev.yml @@ -14,7 +14,7 @@ jobs: HELM_REPO_NAME: openstad-kubernetes HELM_CHART_FOLDER: k8s/openstad GIT_USER_EMAIL: github@ci.push - GIT_USER_NAME: "${{ secrets.GIT_USER_NAME }}" + GIT_USER_NAME: "GitHub CI" DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} HELM_REPO: ${{ secrets.HELM_REPO }} From 4fad8efc6e2c23be86513669e6e96c17ae72b644 Mon Sep 17 00:00:00 2001 From: Rudi van Hierden Date: Fri, 22 Jan 2021 10:58:26 +0100 Subject: [PATCH 22/41] Set git user name to 'GitHub', spaces are not passed --- .github/workflows/gitops-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gitops-dev.yml b/.github/workflows/gitops-dev.yml index 44695b6c5..845c7d54a 100644 --- a/.github/workflows/gitops-dev.yml +++ b/.github/workflows/gitops-dev.yml @@ -14,7 +14,7 @@ jobs: HELM_REPO_NAME: openstad-kubernetes HELM_CHART_FOLDER: k8s/openstad GIT_USER_EMAIL: github@ci.push - GIT_USER_NAME: "GitHub CI" + GIT_USER_NAME: GitHub DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} HELM_REPO: ${{ secrets.HELM_REPO }} From 7790ca42330e1447a03d142783df382fe5c04cc1 Mon Sep 17 00:00:00 2001 From: Rudi van Hierden Date: Fri, 22 Jan 2021 11:16:08 +0100 Subject: [PATCH 23/41] Add ENV vars for docker build --- .github/workflows/gitops-dev.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.github/workflows/gitops-dev.yml b/.github/workflows/gitops-dev.yml index 845c7d54a..f1baddc5b 100644 --- a/.github/workflows/gitops-dev.yml +++ b/.github/workflows/gitops-dev.yml @@ -20,6 +20,22 @@ jobs: HELM_REPO: ${{ secrets.HELM_REPO }} HELM_REPO_WITH_TOKEN: ${{ secrets.HELM_REPO_WITH_TOKEN }} GITOPS_RELEASE_BRANCH: ${{ secrets.GITOPS_RELEASE_BRANCH }} + FRONTED_PORT: 4444 + FRONTEND_MONGO_SCHEME: mongodb://mongo + FRONTEND_MONGO_DB_HOST: mongo + FRONTEND_MONGO_PORT: 27017 + FRONTEND_MINIFY_JS: ON + COOKIE_SECURE_OFF: yes + API: http://localhost:8111 + IMAGE_API_URL: http://localhost:3333 + IMAGE_API_ACCESS_TOKEN: xxxx + SITE_API_KEY: xxxx + DEFAULT_DB: localhost2 + DEFAULT_HOST: localhost:4444 + APP_URL: http://localhost:4444 + APOS_BUNDLE: assets + APOS_MINIFY: 1 + NODE_ENV: production name: gitops commit runs-on: ubuntu-latest From f3877b6c4fd16c8945581e3913f7a04d7f9da512 Mon Sep 17 00:00:00 2001 From: Rudi van Hierden Date: Fri, 22 Jan 2021 11:53:27 +0100 Subject: [PATCH 24/41] Add release branch to workflow --- .github/workflows/gitops-dev.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/gitops-dev.yml b/.github/workflows/gitops-dev.yml index f1baddc5b..10a48d270 100644 --- a/.github/workflows/gitops-dev.yml +++ b/.github/workflows/gitops-dev.yml @@ -6,6 +6,7 @@ on: branches: - development - feature/* + - release/* jobs: gitops: From 044d75959de2f548c89a35b70a97782d90c2db8a Mon Sep 17 00:00:00 2001 From: Rudi van Hierden Date: Fri, 22 Jan 2021 12:06:00 +0100 Subject: [PATCH 25/41] Add branch ref to env vars --- .github/workflows/gitops-dev.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/gitops-dev.yml b/.github/workflows/gitops-dev.yml index 10a48d270..d994c6992 100644 --- a/.github/workflows/gitops-dev.yml +++ b/.github/workflows/gitops-dev.yml @@ -37,6 +37,7 @@ jobs: APOS_BUNDLE: assets APOS_MINIFY: 1 NODE_ENV: production + BRANCH_REF: ${{ github.ref }} name: gitops commit runs-on: ubuntu-latest @@ -58,7 +59,8 @@ jobs: - name: Set outputs id: vars - run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" + run: | + echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" - name: Check outputs run: echo ${{ steps.vars.outputs.sha_short }} @@ -77,5 +79,5 @@ jobs: ./gitops_push shell: bash env: - IMAGE_TAG: ${{ secrets.DOCKER_PUBLIC_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:${{ steps.vars.outputs.sha_short }} + IMAGE_TAG: ${{ secrets.DOCKER_PUBLIC_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:${{ steps.vars.outputs.sha_short }}-${{ github.run_id}} GITOPS_VALUES_FILE: k8s/openstad/environments/dev.values.yaml From 1d21fe2890755966b2fb81632f6f78b8cbd18436 Mon Sep 17 00:00:00 2001 From: Rudi van Hierden Date: Fri, 22 Jan 2021 13:06:15 +0100 Subject: [PATCH 26/41] Add current branch as ENV --- .github/workflows/gitops-dev.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/gitops-dev.yml b/.github/workflows/gitops-dev.yml index d994c6992..812559e12 100644 --- a/.github/workflows/gitops-dev.yml +++ b/.github/workflows/gitops-dev.yml @@ -61,9 +61,12 @@ jobs: id: vars run: | echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" + echo "::set-output name=current_branch::$(git brannch --show-current)" - name: Check outputs - run: echo ${{ steps.vars.outputs.sha_short }} + run: | + echo ${{ steps.vars.outputs.sha_short }} + echo ${{ steps.vars.outputs.current_branch }} - name: Run build script run: | From 5462194c9ecaa74bd21c0a3184e0f83d24aceaa8 Mon Sep 17 00:00:00 2001 From: Rudi van Hierden Date: Fri, 22 Jan 2021 13:08:56 +0100 Subject: [PATCH 27/41] Add bash shell to vars --- .github/workflows/gitops-dev.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/gitops-dev.yml b/.github/workflows/gitops-dev.yml index 812559e12..2ae7e5adb 100644 --- a/.github/workflows/gitops-dev.yml +++ b/.github/workflows/gitops-dev.yml @@ -59,11 +59,13 @@ jobs: - name: Set outputs id: vars + shell: bash run: | echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" echo "::set-output name=current_branch::$(git brannch --show-current)" - name: Check outputs + shell: bash run: | echo ${{ steps.vars.outputs.sha_short }} echo ${{ steps.vars.outputs.current_branch }} From ce689815ee59320f0dd175ba681b501f1c188a5f Mon Sep 17 00:00:00 2001 From: Rudi van Hierden Date: Fri, 22 Jan 2021 13:10:33 +0100 Subject: [PATCH 28/41] Fix typo --- .github/workflows/gitops-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gitops-dev.yml b/.github/workflows/gitops-dev.yml index 2ae7e5adb..2d13d8810 100644 --- a/.github/workflows/gitops-dev.yml +++ b/.github/workflows/gitops-dev.yml @@ -62,7 +62,7 @@ jobs: shell: bash run: | echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" - echo "::set-output name=current_branch::$(git brannch --show-current)" + echo "::set-output name=current_branch::$(git branch --show-current)" - name: Check outputs shell: bash From 3ddb0feb8115650613062ceed54b95e8e3f9c6a1 Mon Sep 17 00:00:00 2001 From: Rudi van Hierden Date: Fri, 22 Jan 2021 13:12:38 +0100 Subject: [PATCH 29/41] Set new image tag --- .github/workflows/gitops-dev.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/gitops-dev.yml b/.github/workflows/gitops-dev.yml index 2d13d8810..c87a7151b 100644 --- a/.github/workflows/gitops-dev.yml +++ b/.github/workflows/gitops-dev.yml @@ -76,7 +76,7 @@ jobs: ./build.sh shell: bash env: - IMAGE_TAG: ${{ secrets.DOCKER_PUBLIC_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:${{ steps.vars.outputs.sha_short }} + IMAGE_TAG: ${{ secrets.DOCKER_PUBLIC_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:${{ steps.vars.outputs.current_branch }}-${{ steps.vars.outputs.sha_short }}-${{ github.run_id}} - name: Run docker push script run: | @@ -84,5 +84,5 @@ jobs: ./gitops_push shell: bash env: - IMAGE_TAG: ${{ secrets.DOCKER_PUBLIC_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:${{ steps.vars.outputs.sha_short }}-${{ github.run_id}} + IMAGE_TAG: ${{ secrets.DOCKER_PUBLIC_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:${{ steps.vars.outputs.current_branch }}-${{ steps.vars.outputs.sha_short }}-${{ github.run_id}} GITOPS_VALUES_FILE: k8s/openstad/environments/dev.values.yaml From 87db14a7df1ee262b169c70dc0f974dccf00d0c3 Mon Sep 17 00:00:00 2001 From: Rudi van Hierden Date: Fri, 22 Jan 2021 13:18:09 +0100 Subject: [PATCH 30/41] Replace slash with dash in branch --- .github/workflows/gitops-dev.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/gitops-dev.yml b/.github/workflows/gitops-dev.yml index c87a7151b..fd774c644 100644 --- a/.github/workflows/gitops-dev.yml +++ b/.github/workflows/gitops-dev.yml @@ -57,12 +57,12 @@ jobs: - name: Install yq run: sudo snap install yq --channel=v3/stable - - name: Set outputs + - name: Set SHA & branch id: vars shell: bash run: | echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" - echo "::set-output name=current_branch::$(git branch --show-current)" + echo "::set-output name=current_branch::${$(git branch --show-current)/\//-}" - name: Check outputs shell: bash From 84fd78660679591e825273521f5c2e2ebe697b05 Mon Sep 17 00:00:00 2001 From: Rudi van Hierden Date: Fri, 22 Jan 2021 13:21:05 +0100 Subject: [PATCH 31/41] Replace slash with dash in branch --- .github/workflows/gitops-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gitops-dev.yml b/.github/workflows/gitops-dev.yml index fd774c644..e5cb80f6f 100644 --- a/.github/workflows/gitops-dev.yml +++ b/.github/workflows/gitops-dev.yml @@ -62,7 +62,7 @@ jobs: shell: bash run: | echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" - echo "::set-output name=current_branch::${$(git branch --show-current)/\//-}" + echo "::set-output name=current_branch::$(git branch --show-current) | sed "s/\//-/g"" - name: Check outputs shell: bash From 8d9a1f480bfddc4efb02fe5295dd6f22cd624603 Mon Sep 17 00:00:00 2001 From: Rudi van Hierden Date: Fri, 22 Jan 2021 13:23:38 +0100 Subject: [PATCH 32/41] Replace slash with dash in branch --- .github/workflows/gitops-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gitops-dev.yml b/.github/workflows/gitops-dev.yml index e5cb80f6f..50058ffc3 100644 --- a/.github/workflows/gitops-dev.yml +++ b/.github/workflows/gitops-dev.yml @@ -62,7 +62,7 @@ jobs: shell: bash run: | echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" - echo "::set-output name=current_branch::$(git branch --show-current) | sed "s/\//-/g"" + echo "::set-output name=current_branch::$(git branch --show-current | sed "s/\//-/g")" - name: Check outputs shell: bash From 722336be4191b19c3c73bd50ad4ffcacfdedd531 Mon Sep 17 00:00:00 2001 From: Rudi van Hierden Date: Fri, 22 Jan 2021 14:34:35 +0100 Subject: [PATCH 33/41] Add master/relase branches & set dev filename through step --- .github/workflows/gitops-dev.yml | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/.github/workflows/gitops-dev.yml b/.github/workflows/gitops-dev.yml index 50058ffc3..0756c8131 100644 --- a/.github/workflows/gitops-dev.yml +++ b/.github/workflows/gitops-dev.yml @@ -4,9 +4,11 @@ name: GitopsDev on: push: branches: + - master - development - feature/* - release/* + - release jobs: gitops: @@ -54,21 +56,23 @@ jobs: - name: Checkout code uses: actions/checkout@v2 - - name: Install yq - run: sudo snap install yq --channel=v3/stable - - name: Set SHA & branch + - name: Set environment to dev + id: deploy_environment + shell: bash + run: | + echo "::set-output name=filename::dev" + + - name: Set commit SHA & current branch id: vars shell: bash run: | echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" echo "::set-output name=current_branch::$(git branch --show-current | sed "s/\//-/g")" - - name: Check outputs - shell: bash - run: | - echo ${{ steps.vars.outputs.sha_short }} - echo ${{ steps.vars.outputs.current_branch }} + - name: Install yq + run: sudo snap install yq --channel=v3/stable + - name: Run build script run: | @@ -85,4 +89,4 @@ jobs: shell: bash env: IMAGE_TAG: ${{ secrets.DOCKER_PUBLIC_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:${{ steps.vars.outputs.current_branch }}-${{ steps.vars.outputs.sha_short }}-${{ github.run_id}} - GITOPS_VALUES_FILE: k8s/openstad/environments/dev.values.yaml + GITOPS_VALUES_FILE: k8s/openstad/environments/${{ steps.deploy_environment.filename }}.values.yaml From b1100a220642278fe820aea9dca9751f599c01d5 Mon Sep 17 00:00:00 2001 From: Stijn van der Vegt Date: Fri, 22 Jan 2021 14:53:41 +0100 Subject: [PATCH 34/41] set gitops_values_file based on branch type --- .github/workflows/gitops-dev.yml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/gitops-dev.yml b/.github/workflows/gitops-dev.yml index 0756c8131..ec2a205b1 100644 --- a/.github/workflows/gitops-dev.yml +++ b/.github/workflows/gitops-dev.yml @@ -40,6 +40,7 @@ jobs: APOS_MINIFY: 1 NODE_ENV: production BRANCH_REF: ${{ github.ref }} + GITOPS_VALUES_FILE: k8s/openstad/environments/dev.values.yaml name: gitops commit runs-on: ubuntu-latest @@ -57,11 +58,17 @@ jobs: uses: actions/checkout@v2 - - name: Set environment to dev - id: deploy_environment + - name: Set environment to acc + id: acc_values_file shell: bash - run: | - echo "::set-output name=filename::dev" + if: contains(github.ref, 'release') + run: echo "k8s/openstad/environments/acc.values.yaml" >> $GITOPS_VALUES_FILE + + - name: Set environment to production + id: prod_values_file + shell: bash + if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/master' + run: echo "k8s/openstad/environments/prod.values.yaml" >> $GITOPS_VALUES_FILE - name: Set commit SHA & current branch id: vars @@ -89,4 +96,3 @@ jobs: shell: bash env: IMAGE_TAG: ${{ secrets.DOCKER_PUBLIC_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:${{ steps.vars.outputs.current_branch }}-${{ steps.vars.outputs.sha_short }}-${{ github.run_id}} - GITOPS_VALUES_FILE: k8s/openstad/environments/${{ steps.deploy_environment.filename }}.values.yaml From 5ff07392ea2981c5f4949bc17a31c41cd9fd203c Mon Sep 17 00:00:00 2001 From: Stijn van der Vegt Date: Fri, 22 Jan 2021 15:08:47 +0100 Subject: [PATCH 35/41] use --- .github/workflows/gitops-dev.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/gitops-dev.yml b/.github/workflows/gitops-dev.yml index ec2a205b1..af10088ce 100644 --- a/.github/workflows/gitops-dev.yml +++ b/.github/workflows/gitops-dev.yml @@ -62,13 +62,13 @@ jobs: id: acc_values_file shell: bash if: contains(github.ref, 'release') - run: echo "k8s/openstad/environments/acc.values.yaml" >> $GITOPS_VALUES_FILE + run: echo "GITOPS_VALUES_FILE=k8s/openstad/environments/acc.values.yaml" >> $GITHUB_ENV - name: Set environment to production id: prod_values_file shell: bash if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/master' - run: echo "k8s/openstad/environments/prod.values.yaml" >> $GITOPS_VALUES_FILE + run: echo "GITOPS_VALUES_FILE=k8s/openstad/environments/prod.values.yaml" >> $GITHUB_ENV - name: Set commit SHA & current branch id: vars From 43c8c8077307cc9b383f1e1540e6a675b021e6f9 Mon Sep 17 00:00:00 2001 From: Rudi van Hierden Date: Thu, 23 Sep 2021 11:08:37 +0200 Subject: [PATCH 36/41] Treat formatted search text as unsafe This fixes the possible HTML injection through the search form in the resource-overview widget. It was possible to inject HTML through the search query, e.g.: ?search=Een%20rode%20kat%20die%20zich%20altijd%20in%20de%20nesten%20werkt%22%3E%3Ca%20href=https://dn.ht/picklecat%3E%3Cimg%20src=https://dikkiedikboeken.nl/wp-content/uploads/2019/07/DD52.jpg%3E%3C/a%3E%3C%2Fa%3E --- CHANGELOG.md | 5 +++++ .../lib/modules/resource-overview-widgets/views/widget.html | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ce7d80aa9..7822bb55f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## URELEASED 2 +* Make embedded auth forms label en button text configurable in widget +* Fix counter button urls in subdir sites +* Fix HTML injection in search form in the resource overview widget + ## v0.20.2 * Fix resource overview widget error: TypeError: Cannot read property 'automaticallyUpdateStatus' of undefined diff --git a/packages/cms/lib/modules/resource-overview-widgets/views/widget.html b/packages/cms/lib/modules/resource-overview-widgets/views/widget.html index 26cf8b857..927bbd7eb 100644 --- a/packages/cms/lib/modules/resource-overview-widgets/views/widget.html +++ b/packages/cms/lib/modules/resource-overview-widgets/views/widget.html @@ -22,7 +22,7 @@ {% if data.widget.formattedSearchText %}
- {{data.widget.formattedSearchText | sanitize | safe}} + {{ data.widget.formattedSearchText }}
{% endif %} From e8d10faf1c7fd8f0c70776d04b5fa9221705d5df Mon Sep 17 00:00:00 2001 From: Ian de Bruin Date: Wed, 15 Sep 2021 13:22:16 +0200 Subject: [PATCH 37/41] Make image size configable for the image widget --- CHANGELOG.md | 3 ++ .../cms/lib/modules/image-widgets/index.js | 34 ++++++++++++++++++- .../modules/image-widgets/views/widget.html | 2 +- 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ce7d80aa9..3a17e248c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## Unreleased +* Make image size configable for the image widget + ## v0.20.2 * Fix resource overview widget error: TypeError: Cannot read property 'automaticallyUpdateStatus' of undefined diff --git a/packages/cms/lib/modules/image-widgets/index.js b/packages/cms/lib/modules/image-widgets/index.js index 85802884f..3a1eac491 100644 --- a/packages/cms/lib/modules/image-widgets/index.js +++ b/packages/cms/lib/modules/image-widgets/index.js @@ -28,6 +28,38 @@ module.exports = { label: 'Textual alternative', type: 'string' }, + { + name: 'displaySize', + type: 'select', + label: 'Display size', + def: 'full', + choices: [ + { + value: 'max', + label: "Max (1600x1600)" + }, + { + value: 'full', + label: "Volledig (1140x1140)", + }, + { + value: 'two-thirds', + label: "Medium-groot (760x760)", + }, + { + value: 'one-half', + label: "Medium (570x700)", + }, + { + value: 'one-third', + label: "Medium-klein (380x700)", + }, + { + value: 'one-sixth', + label: "Klein (190x350)", + }, + ] + }, styleSchema.definition('imageStyles', 'Styles for the image'), ], @@ -36,7 +68,7 @@ module.exports = { { name: 'generalGroup', label: 'General', - fields: ['uploadedImage'] + fields: ['uploadedImage', 'displaySize'] }, { name: 'stylingGroup', diff --git a/packages/cms/lib/modules/image-widgets/views/widget.html b/packages/cms/lib/modules/image-widgets/views/widget.html index 8c067ce60..2680b5c06 100644 --- a/packages/cms/lib/modules/image-widgets/views/widget.html +++ b/packages/cms/lib/modules/image-widgets/views/widget.html @@ -4,7 +4,7 @@ {{data.widget.uploadedImageAlt}} From 2e23827cf7aa0d4b799f5cd5501268634941cfa7 Mon Sep 17 00:00:00 2001 From: Ian de Bruin Date: Wed, 15 Sep 2021 13:29:52 +0200 Subject: [PATCH 38/41] Fixed typo in changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a17e248c..9a1eda5d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ # Changelog ## Unreleased -* Make image size configable for the image widget +* Make image size configurable for the image widget ## v0.20.2 * Fix resource overview widget error: TypeError: Cannot read property 'automaticallyUpdateStatus' of undefined From 0424aab06cbf394e072047ca7d899c920023e3f7 Mon Sep 17 00:00:00 2001 From: Ian de Bruin Date: Wed, 15 Sep 2021 14:46:58 +0200 Subject: [PATCH 39/41] Make image size configurable for the images in the slider widget --- .../cms/lib/modules/slider-widgets/index.js | 32 +++++++++++++++++++ .../modules/slider-widgets/views/widget.html | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/packages/cms/lib/modules/slider-widgets/index.js b/packages/cms/lib/modules/slider-widgets/index.js index 2292115b7..f98ba7a9c 100644 --- a/packages/cms/lib/modules/slider-widgets/index.js +++ b/packages/cms/lib/modules/slider-widgets/index.js @@ -46,6 +46,38 @@ module.exports = { name: 'image', label: 'Image' }, + { + name: 'displaySize', + type: 'select', + label: 'Display size', + def: 'full', + choices: [ + { + value: 'max', + label: "Max (1600x1600)" + }, + { + value: 'full', + label: "Volledig (1140x1140)", + }, + { + value: 'two-thirds', + label: "Medium-groot (760x760)", + }, + { + value: 'one-half', + label: "Medium (570x700)", + }, + { + value: 'one-third', + label: "Medium-klein (380x700)", + }, + { + value: 'one-sixth', + label: "Klein (190x350)", + }, + ] + }, { name: 'linkUrl', type: 'text', diff --git a/packages/cms/lib/modules/slider-widgets/views/widget.html b/packages/cms/lib/modules/slider-widgets/views/widget.html index 90dd06fa5..3fab21d7b 100644 --- a/packages/cms/lib/modules/slider-widgets/views/widget.html +++ b/packages/cms/lib/modules/slider-widgets/views/widget.html @@ -9,7 +9,7 @@
  • From 3a86456dde8f66340811b574d92d92a171a50298 Mon Sep 17 00:00:00 2001 From: Rudi van Hierden Date: Fri, 28 Jan 2022 13:45:17 +0100 Subject: [PATCH 40/41] Remove userformFields --- packages/cms/lib/modules/resource-form-widgets/index.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/cms/lib/modules/resource-form-widgets/index.js b/packages/cms/lib/modules/resource-form-widgets/index.js index 62ab019a8..ed1afc697 100644 --- a/packages/cms/lib/modules/resource-form-widgets/index.js +++ b/packages/cms/lib/modules/resource-form-widgets/index.js @@ -137,9 +137,7 @@ module.exports = { self.load = function (req, widgets, next) { const styles = openstadMap.defaults.styles; const globalData = req.data.global; - - req.data.userFormFields = userFormFields; - + widgets.forEach(async (widget) => { const resourceType = widget.resource ? widget.resource : false; const resourceInfo = resourceType ? resourcesSchema.find((resourceInfo) => resourceInfo.value === resourceType) : false; From e3701187d665c60e6d9df73a2d1c197fc2486125 Mon Sep 17 00:00:00 2001 From: Rudi van Hierden Date: Thu, 5 Aug 2021 10:55:07 +0200 Subject: [PATCH 41/41] Add components URL to global settings This allows the Openstad Components URL (set through .env) to be overwritten on a per-site basis. # Conflicts: # packages/cms/lib/modules/choices-guide-result-widgets/index.js # packages/cms/lib/modules/choices-guide-widgets/index.js # packages/cms/lib/modules/ideas-on-map-widgets/index.js # packages/cms/lib/modules/previous-next-button-block-widgets/index.js --- .../cms/lib/modules/choices-guide-result-widgets/index.js | 2 +- packages/cms/lib/modules/choices-guide-widgets/index.js | 2 +- packages/cms/lib/modules/ideas-on-map-widgets/index.js | 2 +- .../cms/lib/modules/openstad-global/lib/arrangeFields.js | 2 +- packages/cms/lib/modules/openstad-global/lib/fields.js | 8 ++++++++ .../modules/previous-next-button-block-widgets/index.js | 2 +- 6 files changed, 13 insertions(+), 5 deletions(-) diff --git a/packages/cms/lib/modules/choices-guide-result-widgets/index.js b/packages/cms/lib/modules/choices-guide-result-widgets/index.js index e5689d063..24465d64b 100644 --- a/packages/cms/lib/modules/choices-guide-result-widgets/index.js +++ b/packages/cms/lib/modules/choices-guide-result-widgets/index.js @@ -62,7 +62,7 @@ module.exports = { widgets.forEach((widget) => { let apiUrl = self.apos.settings.getOption(req, 'apiUrl') widget.config = JSON.stringify(createConfig(widget, req.data, req.session.jwt, apiUrl, req.data.siteUrl + '/oauth/login?returnTo=' + encodeURIComponent(req.url), apiUrl + '/oauth/logout' )); - widget.openstadComponentsCdn = self.apos.settings.getOption(req, 'siteConfig').openstadComponentsCdn; + widget.openstadComponentsCdn = (req && req.data && req.data.global && req.data.global.openstadComponentsUrl) || self.apos.settings.getOption(req, 'siteConfig').openstadComponentsCdn; const containerId = self.apos.utils.generateId(); widget.containerId = containerId; widget.cssHelperClassesString = widget.cssHelperClasses ? widget.cssHelperClasses.join(' ') : ''; diff --git a/packages/cms/lib/modules/choices-guide-widgets/index.js b/packages/cms/lib/modules/choices-guide-widgets/index.js index 42da4a915..9e354ced0 100644 --- a/packages/cms/lib/modules/choices-guide-widgets/index.js +++ b/packages/cms/lib/modules/choices-guide-widgets/index.js @@ -42,7 +42,7 @@ module.exports = { widgets.forEach((widget) => { widget.config = JSON.stringify(createConfig(widget, req.data, req.session.jwt, self.apos.settings.getOption(req, 'apiUrl'), req.data.siteUrl + '/oauth/login?returnTo=' + encodeURIComponent(req.url) )); - widget.openstadComponentsCdn = self.apos.settings.getOption(req, 'siteConfig').openstadComponentsCdn; + widget.openstadComponentsCdn = (req && req.data && req.data.global && req.data.global.openstadComponentsUrl) || self.apos.settings.getOption(req, 'siteConfig').openstadComponentsCdn; const containerId = self.apos.utils.generateId(); widget.containerId = containerId; widget.cssHelperClassesString = widget.cssHelperClasses ? widget.cssHelperClasses.join(' ') : ''; diff --git a/packages/cms/lib/modules/ideas-on-map-widgets/index.js b/packages/cms/lib/modules/ideas-on-map-widgets/index.js index 08863e08d..d56f6341d 100644 --- a/packages/cms/lib/modules/ideas-on-map-widgets/index.js +++ b/packages/cms/lib/modules/ideas-on-map-widgets/index.js @@ -78,7 +78,7 @@ module.exports = { let config = createConfig(widget, req.data, req.session.jwt, self.apos.settings.getOption(req, 'apiUrl'), req.data.siteUrl + '/oauth/login?{returnTo}', imageProxy, self.apos ); widget.config = JSON.stringify(config); - widget.openstadComponentsCdn = self.apos.settings.getOption(req, 'siteConfig').openstadComponentsCdn; + widget.openstadComponentsCdn = (req && req.data && req.data.global && req.data.global.openstadComponentsUrl) || self.apos.settings.getOption(req, 'siteConfig').openstadComponentsCdn;; const containerId = self.apos.utils.generateId(); widget.containerId = containerId; diff --git a/packages/cms/lib/modules/openstad-global/lib/arrangeFields.js b/packages/cms/lib/modules/openstad-global/lib/arrangeFields.js index 3721cd0f8..1d7530833 100644 --- a/packages/cms/lib/modules/openstad-global/lib/arrangeFields.js +++ b/packages/cms/lib/modules/openstad-global/lib/arrangeFields.js @@ -12,7 +12,7 @@ module.exports = [ { name: 'api', label: 'Url & api instellingen', - fields: ['siteId', 'ideaSlug', 'ideaOverviewSlug', 'editIdeaUrl', 'cacheIdeas'] + fields: ['siteId', 'ideaSlug', 'ideaOverviewSlug', 'editIdeaUrl', 'cacheIdeas', 'openstadComponentsUrl'] }, { diff --git a/packages/cms/lib/modules/openstad-global/lib/fields.js b/packages/cms/lib/modules/openstad-global/lib/fields.js index 5bbf86b6a..bf7d7794f 100644 --- a/packages/cms/lib/modules/openstad-global/lib/fields.js +++ b/packages/cms/lib/modules/openstad-global/lib/fields.js @@ -751,4 +751,12 @@ module.exports = [ choices: rightsChoices, def: 'member' },*/ + + { + type: 'string', + name: 'openstadComponentsUrl', + label: 'Openstad Components URL', + help: 'Specify the URL where the Openstad Components (choice guide, ideas on map etc.) are loaded from. Leave empty to use the default URL.', + def: '' + }, ]; diff --git a/packages/cms/lib/modules/previous-next-button-block-widgets/index.js b/packages/cms/lib/modules/previous-next-button-block-widgets/index.js index 9824e2b14..83d0094fb 100644 --- a/packages/cms/lib/modules/previous-next-button-block-widgets/index.js +++ b/packages/cms/lib/modules/previous-next-button-block-widgets/index.js @@ -47,7 +47,7 @@ module.exports = { nextUrl: widget.nextLabel && req.data.siteUrl + widget.nextUrl, nextLabel: widget.nextLabel, }); - widget.openstadComponentsCdn = self.apos.settings.getOption(req, 'siteConfig').openstadComponentsCdn; + widget.openstadComponentsCdn = (req && req.data && req.data.global && req.data.global.openstadComponentsUrl) || self.apos.settings.getOption(req, 'siteConfig').openstadComponentsCdn; const containerId = self.apos.utils.generateId(); widget.containerId = containerId; widget.cssHelperClassesString = widget.cssHelperClasses ? widget.cssHelperClasses.join(' ') : '';