changed deployment workflow #7
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: DO Kubernetes pipeline | |
on: | |
push: | |
branches: | |
- master | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout master | |
uses: actions/checkout@main | |
- name: Install doctl | |
uses: digitalocean/action-doctl@v2 | |
with: | |
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} | |
- name: Build container image | |
run: docker build -t ${{ secrets.DO_REGISTRY_NAME }}/deepface:$(echo $GITHUB_SHA | head -c7) . | |
- name: Log in to DigitalOcean Container Registry with short-lived credentials | |
run: doctl registry login --expiry-seconds 1200 | |
- name: Push image to DigitalOcean Container Registry | |
run: docker push ${{ secrets.DO_REGISTRY_NAME }}/deepface:$(echo $GITHUB_SHA | head -c7) | |
- name: Update deployment file | |
run: TAG=$(echo $GITHUB_SHA | head -c7) && sed -i 's|<IMAGE>|${{ secrets.DO_REGISTRY_NAME }}/deepface:'${TAG}'|' $GITHUB_WORKSPACE/config/deployment.yml | |
- name: Save DigitalOcean kubeconfig with short-lived credentials | |
run: doctl kubernetes cluster kubeconfig save --expiry-seconds 600 ${{ secrets.K8S_CLUSTER_NAME }} | |
- name: Deploy to DigitalOcean Kubernetes | |
run: kubectl apply -f $GITHUB_WORKSPACE/config/deployment.yml | |
- name: Verify deployment | |
run: kubectl rollout status deployment/deepface |