Skip to content

Merge branch 'dev' into prod #179

Merge branch 'dev' into prod

Merge branch 'dev' into prod #179

Workflow file for this run

name: Prod Deployment
on:
workflow_dispatch:
push:
branches:
- prod
concurrency: prod-deployment
env:
REGISTRY: registry.digitalocean.com/uoft-orientation
TAG: prod
SERVER_IMAGE_NAME: "orientation-server"
CLIENT_IMAGE_NAME: "orientation-client"
DIGITALOCEAN_API_KEY: ${{ secrets.DIGITALOCEAN_API_KEY }}
jobs:
build_server:
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/[email protected]
- name: Build server image
run: cd server && docker build -t orientation-server:prod -f prod.Dockerfile .
- name: Tag server image
run: docker tag orientation-server:prod registry.digitalocean.com/uoft-orientation/orientation-server:prod
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- name: Log in to DigitalOcean Container Registry
run: doctl registry login --expiry-seconds 600
- name: Remove old server image
run: if [ ! -z "$(doctl registry repository list | grep "$(echo $SERVER_IMAGE_NAME)")" ]; then doctl registry repository delete-tag $(echo $SERVER_IMAGE_NAME) $(echo $TAG) --force; else echo "No repository"; fi
- name: Push server image to container registry
run: docker push registry.digitalocean.com/uoft-orientation/orientation-server:prod
build_client:
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/[email protected]
- name: Make envfile
uses: SpicyPizza/[email protected]
with:
envkey_VITE_API_BASE_URL: "https://api.orientation.skule.ca"
file_name: .env
directory: client
- name: Build client image
run: cd client && docker build -t orientation-client:prod -f prod.Dockerfile .
- name: Tag client image
run: docker tag orientation-client:prod registry.digitalocean.com/uoft-orientation/orientation-client:prod
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- name: Log in to DigitalOcean Container Registry
run: doctl registry login --expiry-seconds 600
- name: Remove old client image
run: if [ ! -z "$(doctl registry repository list | grep "$(echo $CLIENT_IMAGE_NAME)")" ]; then doctl registry repository delete-tag $(echo $CLIENT_IMAGE_NAME) $(echo $TAG) --force; else echo "No repository"; fi
- name: Push client image to container registry
run: docker push registry.digitalocean.com/uoft-orientation/orientation-client:prod
- name: Run garbage collector
run: doctl registry garbage-collection start --include-untagged-manifests --force uoft-orientation