Skip to content

Build base image and reuse for main build. #25

Build base image and reuse for main build.

Build base image and reuse for main build. #25

Workflow file for this run

name: Docker Image CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Login to DigitalOcean Container Registry
uses: docker/login-action@v3
with:
registry: registry.digitalocean.com
username: ${{ secrets.DIGITALOCEAN_USERNAME }}
password: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- uses: actions/checkout@v3
- name: Download BlazeFace
uses: actions/checkout@v3
with:
repository: 'hollance/BlazeFace-PyTorch'
path: 'model/blazeface'
- name: Pull latest from DO
run: docker pull registry.digitalocean.com/thesmile/thesmile:latest
- name: Build the Docker image
run: docker build . --file build/Dockerfile --tag thesmile:$(date +%Y%m%d-%s) --tag thesmile:latest
- name: Tag for DO
run: docker image tag thesmile:latest registry.digitalocean.com/thesmile/thesmile:latest
- name: Tag sha for DO
run: docker image tag thesmile:latest registry.digitalocean.com/thesmile/thesmile:$(echo $GITHUB_SHA | head -c7)
- name: Push to DO
run: docker push registry.digitalocean.com/thesmile/thesmile:latest
- name: Push sha to DO
run: docker push registry.digitalocean.com/thesmile/thesmile:$(echo $GITHUB_SHA | head -c7)
- name: Update deployment file
run: TAG=$(echo $GITHUB_SHA | head -c7) && sed -i 's|<IMAGE>|registry.digitalocean.com/thesmile/thesmile:'${TAG}'|' $GITHUB_WORKSPACE/build/k8s/deployment.yaml
- name: Save DigitalOcean kubeconfig with short-lived credentials
run: doctl kubernetes cluster kubeconfig save --expiry-seconds 600 smile-k8s-1-29-1-do-0-nyc3-1711943773962
- name: Set namespace
run: kubectl config set-context --current --namespace thesmile
- name: Deploy to DigitalOcean Kubernetes
run: kubectl apply -f $GITHUB_WORKSPACE/build/k8s/deployment.yaml
- name: Verify deployment
run: kubectl rollout status deployment/thesmile