Skip to content

Commit

Permalink
Merge pull request #628 from CodeForAfrica/chore/merge_develop_to_main
Browse files Browse the repository at this point in the history
Merge `develop` to `main`
  • Loading branch information
kilemensi committed Oct 10, 2023
2 parents 73018e2 + 766248e commit 39694ab
Show file tree
Hide file tree
Showing 418 changed files with 18,051 additions and 12,222 deletions.
84 changes: 84 additions & 0 deletions .github/workflows/codeforafrica-deploy-dev-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Code for Africa | Deploy | DEV

on:
push:
branches: [develop]
paths:
- "apps/codeforafrica/**"
- "Dockerfile.codeforafrica"
- ".github/**"

concurrency:
group: "${{ github.workflow }} @ ${{ github.ref }}"
cancel-in-progress: true

env:
DOKKU_REMOTE_BRANCH: "master"
DOKKU_REMOTE_URL: "ssh://[email protected]"
IMAGE_NAME: "codeforafrica/codeforafrica-ui"
NEXT_PUBLIC_APP_URL: "https://codeforafrica.dev.codeforafrica.org"
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
APP_NAME: codeforafrica-ui

jobs:
deploy:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [18]
os: [ubuntu-latest]
steps:
- name: Cloning repo
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Cache Docker layers
uses: actions/cache@v3
with:
key: ${{ runner.os }}-buildx-${{ github.sha }}
path: /tmp/.buildx-cache
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to DockerHub
uses: docker/login-action@v2
with:
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
username: ${{ secrets.DOCKER_HUB_USERNAME }}

- name: Build Docker image
uses: docker/build-push-action@v3
with:
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 }}
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 }}
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 }}:${{ github.sha }}"

# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cach
- name: Push to Dokku
uses: dokku/[email protected]
with:
git_remote_url: ${{ env.DOKKU_REMOTE_URL }}/${{ env.APP_NAME }}
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}
deploy_docker_image: ${{ env.IMAGE_NAME }}:${{ github.sha }}
103 changes: 103 additions & 0 deletions .github/workflows/codeforafrica-deploy-review-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: Code for Africa | Deploy | REVIEW APP

on:
pull_request:
paths:
- "apps/codeforafrica/**"
- "Dockerfile.codeforafrica"
- ".github/**"
concurrency:
group: "${{ github.workflow }} @ ${{ github.ref }}"
cancel-in-progress: false

env:
DOKKU_REMOTE_BRANCH: "master"
DOKKU_REMOTE_URL: "ssh://[email protected]"
IMAGE_NAME: "codeforafrica/codeforafrica-ui"
ORIGINAL_APP_NAME: "codeforafrica-ui"
NEXT_PUBLIC_APP_URL: "https://codeforafrica-ui-pr-${{github.event.pull_request.number}}.dev.codeforafrica.org"
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
APP_NAME: codeforafrica-ui-pr-${{ github.event.pull_request.number }}

jobs:
review_app:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [18]
os: [ubuntu-latest]
if: github.event_name == 'pull_request' && github.event.action != 'closed'
steps:
- name: Cloning repo
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Cache Docker layers
uses: actions/cache@v3
with:
key: ${{ runner.os }}-buildx-${{ github.sha }}
path: /tmp/.buildx-cache
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to DockerHub
uses: docker/login-action@v2
with:
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
username: ${{ secrets.DOCKER_HUB_USERNAME }}

- name: Build Docker image
uses: docker/build-push-action@v3
with:
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 }}
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 }}:${{ github.sha }}"

- name: Push to dokku
uses: dokku/github-action@master
with:
# create a review app
command: review-apps:create
git_remote_url: ${{ env.DOKKU_REMOTE_URL }}/codeforafrica-ui
# specify a name for the review app
review_app_name: ${{ env.APP_NAME }}
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}
deploy_docker_image: ${{ env.IMAGE_NAME }}:${{ github.sha }}

- name: Update Preview URL
run: (gh pr comment ${{ env.issue-number }} --edit-last --body='${{ env.body }}' || gh pr comment ${{ env.issue-number }} --body='${{ env.body }}')
env:
issue-number: ${{ github.event.pull_request.number }}
body: |
Latest updated Preview URL
| Name | Review |
|-------|--------|
| ${{ env.APP_NAME }} | [Visit](https://${{ env.APP_NAME }}.dev.codeforafrica.org) |
destroy_review_app:
runs-on: ubuntu-latest
# only run when a pull request is closed
if: github.event.action == 'closed'
steps:
- name: Destroy the review app
uses: dokku/github-action@master
with:
# destroy a review app
command: review-apps:destroy
git_remote_url: ${{ env.DOKKU_REMOTE_URL }}/${{ env.APP_NAME }}
# specify a name for the review app
review_app_name: ${{ env.APP_NAME }}
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}
71 changes: 71 additions & 0 deletions Dockerfile.codeforafrica
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
FROM node:18-alpine as node-alpine

RUN apk update \
&& apk upgrade


FROM node-alpine as base

RUN apk add --no-cache libc6-compat

ARG PNPM_VERSION=8.5.0

RUN corepack enable && corepack prepare pnpm@${PNPM_VERSION} --activate

WORKDIR /workspace

COPY pnpm-lock.yaml .

RUN pnpm fetch

FROM base as builder


WORKDIR /workspace

COPY *.yaml *.json ./
COPY packages ./packages
COPY apps/codeforafrica ./apps/codeforafrica

# Use virtual store: https://pnpm.io/cli/fetch#usage-scenario
RUN pnpm install --recursive --offline --frozen-lockfile

ARG PORT=3000 \
MONGODB_URL \
PAYLOAD_SECRET \
NEXT_PUBLIC_APP_URL=http://localhost:3000

RUN pnpm build-next --filter=codeforafrica

ARG PAYLOAD_PUBLIC_APP_URL=${NEXT_PUBLIC_APP_URL}

RUN pnpm build-payload --filter=codeforafrica

FROM builder as runner

RUN rm -rf /var/cache/apk/*

ARG NEXT_PUBLIC_APP_NAME \
NEXT_PUBLIC_APP_URL \
NEXT_PUBLIC_GA_MEASUREMENT_ID \
NEXT_PUBLIC_SEO_DISABLED \
PAYLOAD_CONFIG_PATH="dist/payload.config.js" \
PAYLOAD_PUBLIC_APP_URL \
NEXT_PUBLIC_APP_LOGO_URL \
PORT

ENV NODE_ENV=production \
PAYLOAD_PUBLIC_APP_URL=${NEXT_PUBLIC_APP_URL} \
PORT=${PORT} \
PAYLOAD_CONFIG_PATH=${PAYLOAD_CONFIG_PATH} \
PAYLOAD_SECRET=${PAYLOAD_SECRET} \
MONGODB_URL=${MONGODB_URL} \
NEXT_PUBLIC_APP_LOGO_URL=${NEXT_PUBLIC_APP_LOGO_URL} \
NEXT_PUBLIC_APP_NAME=${NEXT_PUBLIC_APP_NAME} \
NEXT_PUBLIC_APP_URL=${NEXT_PUBLIC_APP_URL}

WORKDIR /workspace/apps/codeforafrica

EXPOSE ${PORT}

CMD [ "node", "dist/server.js" ]
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ exports[`<CommunityPlatforms /> renders unchanged 1`] = `
</div>
</div>
<a
class="MuiTypography-root MuiTypography-inherit MuiLink-root MuiLink-underlineAlways MuiButtonBase-root MuiButton-root MuiButton-contained MuiButton-containedSecondary MuiButton-sizeSmall MuiButton-containedSizeSmall MuiButton-root MuiButton-contained MuiButton-containedSecondary MuiButton-sizeSmall MuiButton-containedSizeSmall active css-1mu9r82-MuiTypography-root-MuiLink-root-MuiButtonBase-root-MuiButton-root"
class="MuiTypography-root MuiTypography-inherit MuiLink-root MuiLink-underlineAlways MuiButtonBase-root MuiButton-root MuiButton-contained MuiButton-containedSecondary MuiButton-sizeSmall MuiButton-containedSizeSmall MuiButton-root MuiButton-contained MuiButton-containedSecondary MuiButton-sizeSmall MuiButton-containedSizeSmall active css-8kdj3b-MuiTypography-root-MuiLink-root-MuiButtonBase-root-MuiButton-root"
href="https://codeforafrica.org"
rel="noreferrer noopener"
tabindex="0"
Expand Down
10 changes: 5 additions & 5 deletions apps/charterafrica/src/components/Dataset/Dataset.snap.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ exports[`<Dataset /> renders unchanged 1`] = `
class="MuiTypography-root MuiTypography-p1 css-l6prdf-MuiTypography-root"
>
<span
class="MuiTypography-root MuiTypography-inherit css-dhy9gx-MuiTypography-root"
class="MuiTypography-root MuiTypography-inherit css-1ruhe-MuiTypography-root"
>
Created January 1, 2021
</span>
Expand All @@ -37,7 +37,7 @@ exports[`<Dataset /> renders unchanged 1`] = `
class="MuiGrid-root MuiGrid-container MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-md-4 css-1phk7xb-MuiGrid-root"
>
<div
class="MuiChip-root MuiChip-filled MuiChip-sizeMedium MuiChip-colorDefault MuiChip-filledDefault css-1puf64w-MuiChip-root"
class="MuiChip-root MuiChip-filled MuiChip-sizeMedium MuiChip-colorDefault MuiChip-filledDefault css-2n8s2x-MuiChip-root"
>
<span
class="MuiChip-label MuiChip-labelMedium css-6od3lo-MuiChip-label"
Expand All @@ -46,7 +46,7 @@ exports[`<Dataset /> renders unchanged 1`] = `
</span>
</div>
<div
class="MuiChip-root MuiChip-filled MuiChip-sizeMedium MuiChip-colorDefault MuiChip-filledDefault css-1g3w73k-MuiChip-root"
class="MuiChip-root MuiChip-filled MuiChip-sizeMedium MuiChip-colorDefault MuiChip-filledDefault css-euezk3-MuiChip-root"
>
<span
class="MuiChip-label MuiChip-labelMedium css-6od3lo-MuiChip-label"
Expand Down Expand Up @@ -83,15 +83,15 @@ exports[`<Dataset /> renders unchanged 1`] = `
Open Dataset
</button>
<div
class="MuiStack-root css-1xe1uy8-MuiStack-root"
class="MuiStack-root css-1fwy3an-MuiStack-root"
>
<div
class="MuiTypography-root MuiTypography-p3 css-1orwtxp-MuiTypography-root"
>
Share Via
</div>
<div
class="MuiStack-root css-6za6r5-MuiStack-root"
class="MuiStack-root css-b6wkik-MuiStack-root"
>
<button
aria-label="twitter"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ exports[`<DatasetCard /> renders unchanged 1`] = `
class="MuiGrid-root MuiGrid-container MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-md-4 css-6thyz8-MuiGrid-root"
>
<div
class="MuiChip-root MuiChip-filled MuiChip-sizeMedium MuiChip-colorDefault MuiChip-filledDefault css-1puf64w-MuiChip-root"
class="MuiChip-root MuiChip-filled MuiChip-sizeMedium MuiChip-colorDefault MuiChip-filledDefault css-2n8s2x-MuiChip-root"
>
<span
class="MuiChip-label MuiChip-labelMedium css-6od3lo-MuiChip-label"
Expand All @@ -67,7 +67,7 @@ exports[`<DatasetCard /> renders unchanged 1`] = `
</span>
</div>
<div
class="MuiChip-root MuiChip-filled MuiChip-sizeMedium MuiChip-colorDefault MuiChip-filledDefault css-1g3w73k-MuiChip-root"
class="MuiChip-root MuiChip-filled MuiChip-sizeMedium MuiChip-colorDefault MuiChip-filledDefault css-euezk3-MuiChip-root"
>
<span
class="MuiChip-label MuiChip-labelMedium css-6od3lo-MuiChip-label"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ exports[`<DatasetFilterBar /> renders unchanged 1`] = `
Datasets
</button>
<a
class="MuiTypography-root MuiTypography-inherit MuiLink-root MuiLink-underlineAlways MuiButtonBase-root MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium css-zehdzx-MuiTypography-root-MuiLink-root-MuiButtonBase-root-MuiButton-root"
class="MuiTypography-root MuiTypography-inherit MuiLink-root MuiLink-underlineAlways MuiButtonBase-root MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium css-1lrcfc-MuiTypography-root-MuiLink-root-MuiButtonBase-root-MuiButton-root"
href="/documents"
tabindex="0"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ exports[`<Datasets /> renders unchanged 1`] = `
Datasets
</button>
<a
class="MuiTypography-root MuiTypography-inherit MuiLink-root MuiLink-underlineAlways MuiButtonBase-root MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium css-zehdzx-MuiTypography-root-MuiLink-root-MuiButtonBase-root-MuiButton-root"
class="MuiTypography-root MuiTypography-inherit MuiLink-root MuiLink-underlineAlways MuiButtonBase-root MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium css-1lrcfc-MuiTypography-root-MuiLink-root-MuiButtonBase-root-MuiButton-root"
href="/documents"
tabindex="0"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ exports[`<DesktopNavBar /> renders unchanged 1`] = `
class="MuiGrid-root MuiGrid-item css-13i4rnv-MuiGrid-root"
>
<a
class="MuiTypography-root MuiTypography-inherit MuiLink-root MuiLink-underlineAlways MuiButtonBase-root active css-ethxoc-MuiTypography-root-MuiLink-root-MuiButtonBase-root"
class="MuiTypography-root MuiTypography-inherit MuiLink-root MuiLink-underlineAlways MuiButtonBase-root active css-1eqh9fg-MuiTypography-root-MuiLink-root-MuiButtonBase-root"
href="/"
tabindex="0"
>
Expand Down
6 changes: 3 additions & 3 deletions apps/charterafrica/src/components/Document/Document.snap.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ exports[`<Document /> renders unchanged 1`] = `
class="MuiGrid-root MuiGrid-container MuiGrid-item MuiGrid-direction-xs-[object Object] MuiGrid-grid-xs-12 MuiGrid-grid-md-4 css-19fdzmu-MuiGrid-root"
>
<a
class="MuiTypography-root MuiTypography-inherit MuiLink-root MuiLink-underlineAlways MuiButtonBase-root MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium active css-1gwheos-MuiTypography-root-MuiLink-root-MuiButtonBase-root-MuiButton-root"
class="MuiTypography-root MuiTypography-inherit MuiLink-root MuiLink-underlineAlways MuiButtonBase-root MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium active css-1cjcswz-MuiTypography-root-MuiLink-root-MuiButtonBase-root-MuiButton-root"
href="/"
tabindex="0"
>
Expand All @@ -56,15 +56,15 @@ exports[`<Document /> renders unchanged 1`] = `
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 css-mqmitf-MuiGrid-root"
>
<div
class="MuiStack-root css-plcmrn-MuiStack-root"
class="MuiStack-root css-m2meqv-MuiStack-root"
>
<div
class="MuiTypography-root MuiTypography-p3 css-1orwtxp-MuiTypography-root"
>
Share this document
</div>
<div
class="MuiStack-root css-6za6r5-MuiStack-root"
class="MuiStack-root css-b6wkik-MuiStack-root"
>
<button
aria-label="twitter"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ exports[`<Documents /> renders unchanged 1`] = `
:
</p>
<a
class="MuiTypography-root MuiTypography-inherit MuiLink-root MuiLink-underlineAlways MuiButtonBase-root MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium css-17xaaej-MuiTypography-root-MuiLink-root-MuiButtonBase-root-MuiButton-root"
class="MuiTypography-root MuiTypography-inherit MuiLink-root MuiLink-underlineAlways MuiButtonBase-root MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium css-etikzf-MuiTypography-root-MuiLink-root-MuiButtonBase-root-MuiButton-root"
href="/datasets"
tabindex="0"
>
Expand Down
Loading

0 comments on commit 39694ab

Please sign in to comment.