From 091389cc74ffff4c553dc13643457d8526d25922 Mon Sep 17 00:00:00 2001 From: Kevin Koech Date: Thu, 5 Oct 2023 18:13:35 +0300 Subject: [PATCH 01/11] Deploy to prod --- .github/workflows/codeforafrica-deploy-prod.yml | 14 +++++++++----- apps/codeforafrica/package.json | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/codeforafrica-deploy-prod.yml b/.github/workflows/codeforafrica-deploy-prod.yml index c40a29b54..8904f1955 100644 --- a/.github/workflows/codeforafrica-deploy-prod.yml +++ b/.github/workflows/codeforafrica-deploy-prod.yml @@ -2,7 +2,7 @@ name: Code for Africa | Deploy | PROD on: push: - branches: [main] + branches: [feature-auto-deploy] # This allows a subsequently queued workflow run to interrupt previous runs concurrency: @@ -14,8 +14,10 @@ env: DOKKU_REMOTE_URL: "ssh://dokku@ui-1.prod.codeforafrica.org/codeforafrica-ui" IMAGE_NAME: "codeforafrica/codeforafrica-ui" APP: "codeforafrica" + APP_NAME: "codeforafrica-ui" VERSION_FILE_NAME: "./apps/codeforafrica/package.json" GIT_PUSH_FLAGS: "--force" + NEXT_PUBLIC_APP_URL: "https://codeforafrica.prod.codeforafrica.org" jobs: deploy: @@ -70,16 +72,18 @@ jobs: username: ${{ secrets.DOCKER_HUB_USERNAME }} - name: Build Docker image - if: steps.version-check.outputs.changed == 'true' uses: docker/build-push-action@v3 with: build-args: | - APP=${{ env.APP }} - GHOST_API_KEY=${{ secrets.GHOST_API_KEY }} - GOOGLE_API_KEY=${{ secrets.GOOGLE_API_KEY }} + MONGODB_URL=${{ secrets.CODEFORAFRICA_MONGO_URL }}/${{ env.APP_NAME }} + NEXT_PUBLIC_APP_URL=${{ env.NEXT_PUBLIC_APP_URL }} + PAYLOAD_SECRET=${{ secrets.CODEFORAFRICA_PAYLOAD_SECRET_KEY }} + NEXT_PUBLIC_APP_LOGO_URL=${{ secrets.NEXT_PUBLIC_APP_CFA_LOGO_URL }} + NEXT_PUBLIC_APP_NAME=${{ secrets.NEXT_PUBLIC_APP_CFA_NAME }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new context: . + file: ./Dockerfile.codeforafrica push: true tags: "${{ env.IMAGE_NAME }}:${{ steps.version-check.outputs.version }}" diff --git a/apps/codeforafrica/package.json b/apps/codeforafrica/package.json index 3f3a101f2..fa0e036e2 100644 --- a/apps/codeforafrica/package.json +++ b/apps/codeforafrica/package.json @@ -1,6 +1,6 @@ { "name": "codeforafrica", - "version": "1.0.40", + "version": "1.0.41", "private": true, "author": "Code for Africa ", "description": "This is the main CFA site.", From a429c1a771b1a70bfdc5c926b3e4fec1ac90107a Mon Sep 17 00:00:00 2001 From: Kevin Koech Date: Thu, 5 Oct 2023 18:27:15 +0300 Subject: [PATCH 02/11] Deploy to prod --- .github/workflows/codeforafrica-deploy-prod.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codeforafrica-deploy-prod.yml b/.github/workflows/codeforafrica-deploy-prod.yml index 8904f1955..2a2d2a281 100644 --- a/.github/workflows/codeforafrica-deploy-prod.yml +++ b/.github/workflows/codeforafrica-deploy-prod.yml @@ -11,7 +11,7 @@ concurrency: env: DOKKU_REMOTE_BRANCH: "master" - DOKKU_REMOTE_URL: "ssh://dokku@ui-1.prod.codeforafrica.org/codeforafrica-ui" + DOKKU_REMOTE_URL: "ssh://azureuser@ui-1.prod.codeforafrica.org/codeforafrica-ui" IMAGE_NAME: "codeforafrica/codeforafrica-ui" APP: "codeforafrica" APP_NAME: "codeforafrica-ui" From 228787e2a24efc8249dbd990e38b0b0ca00a00d5 Mon Sep 17 00:00:00 2001 From: Kevin Koech Date: Thu, 5 Oct 2023 18:32:44 +0300 Subject: [PATCH 03/11] deploy on bump version --- apps/codeforafrica/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/codeforafrica/package.json b/apps/codeforafrica/package.json index fa0e036e2..26267091e 100644 --- a/apps/codeforafrica/package.json +++ b/apps/codeforafrica/package.json @@ -1,6 +1,6 @@ { "name": "codeforafrica", - "version": "1.0.41", + "version": "1.0.42", "private": true, "author": "Code for Africa ", "description": "This is the main CFA site.", From 393df45a5e3cc2df8564fcf4761e1fc36c169f8a Mon Sep 17 00:00:00 2001 From: Kevin Koech Date: Fri, 6 Oct 2023 10:06:10 +0300 Subject: [PATCH 04/11] Test push --- .github/workflows/codeforafrica-deploy-prod.yml | 2 +- apps/codeforafrica/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/codeforafrica-deploy-prod.yml b/.github/workflows/codeforafrica-deploy-prod.yml index 2a2d2a281..8904f1955 100644 --- a/.github/workflows/codeforafrica-deploy-prod.yml +++ b/.github/workflows/codeforafrica-deploy-prod.yml @@ -11,7 +11,7 @@ concurrency: env: DOKKU_REMOTE_BRANCH: "master" - DOKKU_REMOTE_URL: "ssh://azureuser@ui-1.prod.codeforafrica.org/codeforafrica-ui" + DOKKU_REMOTE_URL: "ssh://dokku@ui-1.prod.codeforafrica.org/codeforafrica-ui" IMAGE_NAME: "codeforafrica/codeforafrica-ui" APP: "codeforafrica" APP_NAME: "codeforafrica-ui" diff --git a/apps/codeforafrica/package.json b/apps/codeforafrica/package.json index 26267091e..e26f05c93 100644 --- a/apps/codeforafrica/package.json +++ b/apps/codeforafrica/package.json @@ -1,6 +1,6 @@ { "name": "codeforafrica", - "version": "1.0.42", + "version": "1.0.43", "private": true, "author": "Code for Africa ", "description": "This is the main CFA site.", From 38edbe00831eef24c38f4e48678c3ae2f08c8e24 Mon Sep 17 00:00:00 2001 From: Kevin Koech Date: Fri, 6 Oct 2023 10:29:42 +0300 Subject: [PATCH 05/11] Update Push to dokku action --- .github/workflows/codeforafrica-deploy-prod.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/codeforafrica-deploy-prod.yml b/.github/workflows/codeforafrica-deploy-prod.yml index 8904f1955..d1a613464 100644 --- a/.github/workflows/codeforafrica-deploy-prod.yml +++ b/.github/workflows/codeforafrica-deploy-prod.yml @@ -99,5 +99,4 @@ jobs: with: branch: ${{ env.DOKKU_REMOTE_BRANCH }} ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }} - git_push_flags: ${{ env.GIT_PUSH_FLAGS }} git_remote_url: ${{ env.DOKKU_REMOTE_URL }} From 2108e48fea3f4a8aa8ffa2b6da22d6196a4454ca Mon Sep 17 00:00:00 2001 From: Kevin Koech Date: Fri, 6 Oct 2023 10:32:59 +0300 Subject: [PATCH 06/11] Build docker image only when it changes --- .github/workflows/codeforafrica-deploy-prod.yml | 1 + apps/codeforafrica/package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/codeforafrica-deploy-prod.yml b/.github/workflows/codeforafrica-deploy-prod.yml index d1a613464..92e61503d 100644 --- a/.github/workflows/codeforafrica-deploy-prod.yml +++ b/.github/workflows/codeforafrica-deploy-prod.yml @@ -72,6 +72,7 @@ jobs: username: ${{ secrets.DOCKER_HUB_USERNAME }} - name: Build Docker image + if: steps.version-check.outputs.changed == 'true' uses: docker/build-push-action@v3 with: build-args: | diff --git a/apps/codeforafrica/package.json b/apps/codeforafrica/package.json index e26f05c93..93fca7fa2 100644 --- a/apps/codeforafrica/package.json +++ b/apps/codeforafrica/package.json @@ -1,6 +1,6 @@ { "name": "codeforafrica", - "version": "1.0.43", + "version": "1.0.44", "private": true, "author": "Code for Africa ", "description": "This is the main CFA site.", From 6500025753c62ac6818d438c3e316e5825169b6c Mon Sep 17 00:00:00 2001 From: Kevin Koech Date: Fri, 6 Oct 2023 11:51:27 +0300 Subject: [PATCH 07/11] update deploy image --- .github/workflows/codeforafrica-deploy-prod.yml | 2 +- apps/codeforafrica/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/codeforafrica-deploy-prod.yml b/.github/workflows/codeforafrica-deploy-prod.yml index 92e61503d..db3966747 100644 --- a/.github/workflows/codeforafrica-deploy-prod.yml +++ b/.github/workflows/codeforafrica-deploy-prod.yml @@ -98,6 +98,6 @@ jobs: if: steps.version-check.outputs.changed == 'true' uses: dokku/github-action@v1.4.0 with: - branch: ${{ env.DOKKU_REMOTE_BRANCH }} + deploy_docker_image: ${{ env.IMAGE_NAME }}:${{ steps.version-check.outputs.version }} ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }} git_remote_url: ${{ env.DOKKU_REMOTE_URL }} diff --git a/apps/codeforafrica/package.json b/apps/codeforafrica/package.json index 93fca7fa2..6a3ed882d 100644 --- a/apps/codeforafrica/package.json +++ b/apps/codeforafrica/package.json @@ -1,6 +1,6 @@ { "name": "codeforafrica", - "version": "1.0.44", + "version": "1.0.45", "private": true, "author": "Code for Africa ", "description": "This is the main CFA site.", From bb5dc8700bc70bea23d7d072bf3470b90587462f Mon Sep 17 00:00:00 2001 From: Kevin Koech Date: Fri, 6 Oct 2023 12:09:02 +0300 Subject: [PATCH 08/11] Set branch to main --- .github/workflows/codeforafrica-deploy-prod.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codeforafrica-deploy-prod.yml b/.github/workflows/codeforafrica-deploy-prod.yml index db3966747..e9c49f27f 100644 --- a/.github/workflows/codeforafrica-deploy-prod.yml +++ b/.github/workflows/codeforafrica-deploy-prod.yml @@ -2,7 +2,7 @@ name: Code for Africa | Deploy | PROD on: push: - branches: [feature-auto-deploy] + branches: [main] # This allows a subsequently queued workflow run to interrupt previous runs concurrency: From 8f16204ad12b1bd6a7a049991f38d66f129b4ca2 Mon Sep 17 00:00:00 2001 From: Kevin Koech Date: Fri, 6 Oct 2023 14:20:17 +0300 Subject: [PATCH 09/11] Implement feedback --- .github/workflows/codeforafrica-deploy-dev-app.yml | 6 +++--- .github/workflows/codeforafrica-deploy-prod.yml | 13 ++++++------- .../workflows/codeforafrica-deploy-review-app.yml | 6 +++--- apps/codeforafrica/package.json | 2 +- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/.github/workflows/codeforafrica-deploy-dev-app.yml b/.github/workflows/codeforafrica-deploy-dev-app.yml index ff34db80d..c859207b9 100644 --- a/.github/workflows/codeforafrica-deploy-dev-app.yml +++ b/.github/workflows/codeforafrica-deploy-dev-app.yml @@ -56,11 +56,11 @@ jobs: build-args: | MONGODB_URL=${{ secrets.CODEFORAFRICA_MONGO_URL }}/${{ env.APP_NAME }} NEXT_PUBLIC_APP_URL=${{ env.NEXT_PUBLIC_APP_URL }} - PAYLOAD_SECRET=${{ secrets.CODEFORAFRICA_PAYLOAD_SECRET_KEY }} + PAYLOAD_SECRET=${{ secrets.CODEFORAFRICA_PAYLOAD_SECRET }} GHOST_URL=${{ secrets.GHOST_URL }} GHOST_API_KEY=${{ secrets.GHOST_API_KEY }} - NEXT_PUBLIC_APP_LOGO_URL=${{ secrets.NEXT_PUBLIC_APP_CFA_LOGO_URL }} - NEXT_PUBLIC_APP_NAME=${{ secrets.NEXT_PUBLIC_APP_CFA_NAME }} + NEXT_PUBLIC_APP_LOGO_URL=${{ secrets.NEXT_PUBLIC_APP_CODEFORAFRICA_LOGO_URL }} + NEXT_PUBLIC_APP_NAME=${{ secrets.NEXT_PUBLIC_APP_CODEFORAFRICA_NAME }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new context: . diff --git a/.github/workflows/codeforafrica-deploy-prod.yml b/.github/workflows/codeforafrica-deploy-prod.yml index e9c49f27f..5f0a9ec53 100644 --- a/.github/workflows/codeforafrica-deploy-prod.yml +++ b/.github/workflows/codeforafrica-deploy-prod.yml @@ -2,7 +2,7 @@ name: Code for Africa | Deploy | PROD on: push: - branches: [main] + branches: [feature-auto-deploy] # This allows a subsequently queued workflow run to interrupt previous runs concurrency: @@ -14,10 +14,9 @@ env: DOKKU_REMOTE_URL: "ssh://dokku@ui-1.prod.codeforafrica.org/codeforafrica-ui" IMAGE_NAME: "codeforafrica/codeforafrica-ui" APP: "codeforafrica" - APP_NAME: "codeforafrica-ui" VERSION_FILE_NAME: "./apps/codeforafrica/package.json" GIT_PUSH_FLAGS: "--force" - NEXT_PUBLIC_APP_URL: "https://codeforafrica.prod.codeforafrica.org" + NEXT_PUBLIC_APP_URL: "https://cfa.dev.codeforafrica.org" jobs: deploy: @@ -76,11 +75,11 @@ jobs: uses: docker/build-push-action@v3 with: build-args: | - MONGODB_URL=${{ secrets.CODEFORAFRICA_MONGO_URL }}/${{ env.APP_NAME }} + MONGODB_URL=${{ secrets.CODEFORAFRICA_MONGODB_URL }} NEXT_PUBLIC_APP_URL=${{ env.NEXT_PUBLIC_APP_URL }} - PAYLOAD_SECRET=${{ secrets.CODEFORAFRICA_PAYLOAD_SECRET_KEY }} - NEXT_PUBLIC_APP_LOGO_URL=${{ secrets.NEXT_PUBLIC_APP_CFA_LOGO_URL }} - NEXT_PUBLIC_APP_NAME=${{ secrets.NEXT_PUBLIC_APP_CFA_NAME }} + PAYLOAD_SECRET=${{ secrets.CODEFORAFRICA_PAYLOAD_SECRET }} + NEXT_PUBLIC_APP_LOGO_URL=${{ secrets.NEXT_PUBLIC_APP_CODEFORAFRICA_LOGO_URL }} + NEXT_PUBLIC_APP_NAME=${{ secrets.NEXT_PUBLIC_APP_CODEFORAFRICA_NAME }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new context: . diff --git a/.github/workflows/codeforafrica-deploy-review-app.yml b/.github/workflows/codeforafrica-deploy-review-app.yml index 0d2f232e6..6913b85ae 100644 --- a/.github/workflows/codeforafrica-deploy-review-app.yml +++ b/.github/workflows/codeforafrica-deploy-review-app.yml @@ -56,9 +56,9 @@ jobs: build-args: | MONGODB_URL=${{ secrets.CODEFORAFRICA_MONGO_URL }}/${{ env.APP_NAME }} NEXT_PUBLIC_APP_URL=${{ env.NEXT_PUBLIC_APP_URL }} - PAYLOAD_SECRET=${{ secrets.CODEFORAFRICA_PAYLOAD_SECRET_KEY }} - NEXT_PUBLIC_APP_LOGO_URL=${{ secrets.NEXT_PUBLIC_APP_CFA_LOGO_URL }} - NEXT_PUBLIC_APP_NAME=${{ secrets.NEXT_PUBLIC_APP_CFA_NAME }} + PAYLOAD_SECRET=${{ secrets.CODEFORAFRICA_PAYLOAD_SECRET }} + NEXT_PUBLIC_APP_LOGO_URL=${{ secrets.NEXT_PUBLIC_APP_CODEFORAFRICA_LOGO_URL }} + NEXT_PUBLIC_APP_NAME=${{ secrets.NEXT_PUBLIC_APP_CODEFORAFRICA_NAME }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new context: . diff --git a/apps/codeforafrica/package.json b/apps/codeforafrica/package.json index 6a3ed882d..1e2289bcc 100644 --- a/apps/codeforafrica/package.json +++ b/apps/codeforafrica/package.json @@ -1,6 +1,6 @@ { "name": "codeforafrica", - "version": "1.0.45", + "version": "1.0.46", "private": true, "author": "Code for Africa ", "description": "This is the main CFA site.", From d17d782e4ab14ff0fc22f17b6cd417a4e58996af Mon Sep 17 00:00:00 2001 From: Kevin Koech Date: Fri, 6 Oct 2023 16:15:36 +0300 Subject: [PATCH 10/11] Rename variables --- .github/workflows/codeforafrica-deploy-dev-app.yml | 4 ++-- .github/workflows/codeforafrica-deploy-prod.yml | 4 ++-- .github/workflows/codeforafrica-deploy-review-app.yml | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/codeforafrica-deploy-dev-app.yml b/.github/workflows/codeforafrica-deploy-dev-app.yml index c859207b9..86aecf57d 100644 --- a/.github/workflows/codeforafrica-deploy-dev-app.yml +++ b/.github/workflows/codeforafrica-deploy-dev-app.yml @@ -59,8 +59,8 @@ jobs: PAYLOAD_SECRET=${{ secrets.CODEFORAFRICA_PAYLOAD_SECRET }} GHOST_URL=${{ secrets.GHOST_URL }} GHOST_API_KEY=${{ secrets.GHOST_API_KEY }} - NEXT_PUBLIC_APP_LOGO_URL=${{ secrets.NEXT_PUBLIC_APP_CODEFORAFRICA_LOGO_URL }} - NEXT_PUBLIC_APP_NAME=${{ secrets.NEXT_PUBLIC_APP_CODEFORAFRICA_NAME }} + NEXT_PUBLIC_APP_LOGO_URL=${{ secrets.NEXT_PUBLIC_CODEFORAFRICA_APP_LOGO_URL }} + NEXT_PUBLIC_APP_NAME=${{ secrets.NEXT_PUBLIC_CODEFORAFRICA_APP_NAME }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new context: . diff --git a/.github/workflows/codeforafrica-deploy-prod.yml b/.github/workflows/codeforafrica-deploy-prod.yml index 5f0a9ec53..3977839b6 100644 --- a/.github/workflows/codeforafrica-deploy-prod.yml +++ b/.github/workflows/codeforafrica-deploy-prod.yml @@ -78,8 +78,8 @@ jobs: MONGODB_URL=${{ secrets.CODEFORAFRICA_MONGODB_URL }} NEXT_PUBLIC_APP_URL=${{ env.NEXT_PUBLIC_APP_URL }} PAYLOAD_SECRET=${{ secrets.CODEFORAFRICA_PAYLOAD_SECRET }} - NEXT_PUBLIC_APP_LOGO_URL=${{ secrets.NEXT_PUBLIC_APP_CODEFORAFRICA_LOGO_URL }} - NEXT_PUBLIC_APP_NAME=${{ secrets.NEXT_PUBLIC_APP_CODEFORAFRICA_NAME }} + NEXT_PUBLIC_APP_LOGO_URL=${{ secrets.NEXT_PUBLIC_CODEFORAFRICA_APP_LOGO_URL }} + NEXT_PUBLIC_APP_NAME=${{ secrets.NEXT_PUBLIC_CODEFORAFRICA_APP_NAME }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new context: . diff --git a/.github/workflows/codeforafrica-deploy-review-app.yml b/.github/workflows/codeforafrica-deploy-review-app.yml index 6913b85ae..59b4c3119 100644 --- a/.github/workflows/codeforafrica-deploy-review-app.yml +++ b/.github/workflows/codeforafrica-deploy-review-app.yml @@ -57,8 +57,8 @@ jobs: MONGODB_URL=${{ secrets.CODEFORAFRICA_MONGO_URL }}/${{ env.APP_NAME }} NEXT_PUBLIC_APP_URL=${{ env.NEXT_PUBLIC_APP_URL }} PAYLOAD_SECRET=${{ secrets.CODEFORAFRICA_PAYLOAD_SECRET }} - NEXT_PUBLIC_APP_LOGO_URL=${{ secrets.NEXT_PUBLIC_APP_CODEFORAFRICA_LOGO_URL }} - NEXT_PUBLIC_APP_NAME=${{ secrets.NEXT_PUBLIC_APP_CODEFORAFRICA_NAME }} + NEXT_PUBLIC_APP_LOGO_URL=${{ secrets.NEXT_PUBLIC_CODEFORAFRICA_APP_LOGO_URL }} + NEXT_PUBLIC_APP_NAME=${{ secrets.NEXT_PUBLIC_CODEFORAFRICA_APP_NAME }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new context: . From ee1bb68464d4f8f110aaa7dba7027497ed3432ce Mon Sep 17 00:00:00 2001 From: Kevin Koech Date: Fri, 6 Oct 2023 16:41:09 +0300 Subject: [PATCH 11/11] Set branch to main --- .github/workflows/codeforafrica-deploy-prod.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codeforafrica-deploy-prod.yml b/.github/workflows/codeforafrica-deploy-prod.yml index 3977839b6..6bbf5cd48 100644 --- a/.github/workflows/codeforafrica-deploy-prod.yml +++ b/.github/workflows/codeforafrica-deploy-prod.yml @@ -2,7 +2,7 @@ name: Code for Africa | Deploy | PROD on: push: - branches: [feature-auto-deploy] + branches: [main] # This allows a subsequently queued workflow run to interrupt previous runs concurrency: