Fixing up file path for deployment #23
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: 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 | |