Merge branch 'main' into chore/build-arm-image #26
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Code for Africa | Deploy | DEV | |
on: | |
push: | |
branches: | |
- main | |
- chore/build-arm-image | |
paths: | |
- "apps/codeforafrica/**" | |
- "Dockerfile" | |
- ".github/workflows/codeforafrica-deploy-dev-app.yml" | |
concurrency: | |
group: "${{ github.workflow }} @ ${{ github.ref }}" | |
cancel-in-progress: true | |
env: | |
APP_NAME: codeforafrica-ui | |
DOKKU_REMOTE_BRANCH: "master" | |
DOKKU_REMOTE_URL: "ssh://azureuser@ui-1.dev.codeforafrica.org" | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
IMAGE_NAME: "codeforafrica/codeforafrica-ui" | |
NEXT_PUBLIC_APP_URL: "https://codeforafrica-ui.dev.codeforafrica.org" | |
SENTRY_ENVIRONMENT: "development" | |
jobs: | |
deploy: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
node-version: [20.16] | |
os: [ubuntu-latest] | |
steps: | |
- name: Cloning repo | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
# Add support for more platforms with QEMU (optional) | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Cache Docker layers | |
uses: actions/cache@v4 | |
with: | |
key: ${{ runner.os }}-buildx-${{ github.sha }} | |
path: /tmp/.buildx-cache | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
- name: Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
- name: Build Docker image | |
uses: docker/build-push-action@v5 | |
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 }} | |
NEXT_PUBLIC_APP_LOGO_URL=${{ secrets.NEXT_PUBLIC_CODEFORAFRICA_APP_LOGO_URL }} | |
NEXT_PUBLIC_APP_NAME=${{ secrets.NEXT_PUBLIC_CODEFORAFRICA_APP_NAME }} | |
SENTRY_ENVIRONMENT=${{ env.SENTRY_ENVIRONMENT }} | |
SENTRY_ORG=${{ secrets.SENTRY_ORG }} | |
SENTRY_PROJECT=${{ secrets.CODEFORAFRICA_SENTRY_PROJECT }} | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache-new | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
secrets: | | |
"sentry_auth_token=${{ secrets.SENTRY_AUTH_TOKEN }}" | |
tags: "${{ env.IMAGE_NAME }}:${{ github.sha }}" | |
target: codeforafrica-runner | |
# 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/github-action@v1.4.0 | |
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 }} |