Skip to content

Commit

Permalink
Merge pull request #685 from CodeForAfrica/feature/auto-deploy-vpnman…
Browse files Browse the repository at this point in the history
…ager

Automate deployment to dev
  • Loading branch information
koechkevin authored Apr 17, 2024
2 parents f012d18 + d8b7c8e commit 6665e84
Showing 1 changed file with 80 additions and 0 deletions.
80 changes: 80 additions & 0 deletions .github/workflows/vpnmanager-deploy-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: VPN Manager | Deploy | DEV

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

# This allows a subsequently queued workflow run to interrupt previous runs
concurrency:
group: "${{ github.workflow }} @ ${{ github.ref }}"
cancel-in-progress: true

env:
DOKKU_REMOTE_URL: "ssh://[email protected]/vpnmanager"
IMAGE_NAME: "codeforafrica/vpnmanager"
SENTRY_ENV: "development"

jobs:
deploy:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [18]
os: [ubuntu-latest]
steps:
- name: Checkout
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: |
SENTRY_DSN=${{ secrets.VPNMANAGER_SENTRY_DSN }}
SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ENV=${{ env.SENTRY_ENV }}
SENTRY_ORG=${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT=${{ secrets.VPNMANAGER_SENTRY_PROJECT }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
context: .
file: ./Dockerfile.vpnmanager
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-cache
- name: Push to Dokku
uses: dokku/[email protected]
with:
git_remote_url: ${{ env.DOKKU_REMOTE_URL }}
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}
deploy_docker_image: ${{ env.IMAGE_NAME }}:${{ github.sha }}

0 comments on commit 6665e84

Please sign in to comment.