Skip to content

Commit

Permalink
Merge pull request #778 from CodeForAfrica/roboshield/push-to-prod
Browse files Browse the repository at this point in the history
@/Roboshield deploy to prod
  • Loading branch information
koechkevin authored Jul 16, 2024
2 parents b012959 + 2e8da6a commit 97f48fc
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 1 deletion.
99 changes: 99 additions & 0 deletions .github/workflows/roboshield-deploy-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: RoboShield | Deploy | PROD

on:
push:
branches: [main]
paths:
- "apps/roboshield/**"
- "Dockerfile"
- ".github/workflows/roboshield-deploy-prod.yml"

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

env:
APP_NAME: roboshield-ui
DOKKU_REMOTE_BRANCH: "master"
DOKKU_REMOTE_URL: "ssh://[email protected]"
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
IMAGE_NAME: "codeforafrica/roboshield"
NEXT_PUBLIC_APP_URL: "https://roboshield-ui.prod.codeforafrica.org"
SENTRY_ENVIRONMENT: "production"
VERSION_FILE_NAME: "./apps/roboshield/package.json"

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

- name: Check if version is bumped
id: version-check
uses: EndBug/version-check@v2
with:
diff-search: true
file-name: "${{ env.VERSION_FILE_NAME }}"

- 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: |
MONGO_URL=${{ secrets.ROBOSHIELD_MONGO_URL }}
NEXT_PUBLIC_APP_URL=${{ env.NEXT_PUBLIC_APP_URL }}
NEXT_PUBLIC_SENTRY_DSN=${{ secrets.ROBOSHIELD_SENTRY_DSN }}
PAYLOAD_SECRET=${{ secrets.ROBOSHIELD_PAYLOAD_SECRET }}
SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ENVIRONMENT=${{ env.SENTRY_ENVIRONMENT }}
SENTRY_ORG=${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT=${{ secrets.ROBOSHIELD_SENTRY_PROJECT }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
context: .
target: roboshield-runner
file: Dockerfile
push: true
tags: "${{ env.IMAGE_NAME }}:${{ steps.version-check.outputs.version }}"

# 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-cache
- 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 }}:${{ steps.version-check.outputs.version }}
2 changes: 1 addition & 1 deletion apps/roboshield/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "roboshield",
"version": "0.1.0",
"version": "0.1.4",
"private": true,
"scripts": {
"build-server": "tsc --project tsconfig.server.json",
Expand Down

0 comments on commit 97f48fc

Please sign in to comment.