refactor for modularity (#6) #15
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: DigialOcean Image Builder | |
on: | |
push: | |
branches: | |
- develop | |
paths: | |
- ".github/workflows/**" | |
- "main.py" | |
- "Dockerfile" | |
- "requirements.txt" | |
- "config/**" | |
jobs: | |
build_and_push: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the Repo | |
uses: actions/checkout@v2 | |
- name: Build Image | |
run: docker build -t registry.digitalocean.com/s6containers/cavbot2:$(echo $GITHUB_SHA | head -c7) . | |
- name: Install doctl | |
uses: digitalocean/action-doctl@v2 | |
with: | |
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} | |
- name: Log in to DO Container Registry | |
run: doctl registry login --expiry-seconds 600 | |
- name: Push image to DO Container Registry | |
run: docker push registry.digitalocean.com/s6containers/cavbot2:$(echo $GITHUB_SHA | head -c7) | |
- name: Update Deployment File | |
run: TAG=$(echo $GITHUB_SHA | head -c7) && sed -i 's|<IMAGE>|registry.digitalocean.com/s6containers/cavbot2:'${TAG}'|' $GITHUB_WORKSPACE/config/deployment.yml | |
- name: Save DO kubeconfig with short-lived credentials | |
run: doctl kubernetes cluster kubeconfig save --expiry-seconds 600 cav-kube | |
- name: Deploy to DO Cluster | |
run: kubectl apply -f $GITHUB_WORKSPACE/config/deployment.yml | |
- name: Verify deployment | |
run: kubectl rollout status deployment/cavbot2-deployment -n 7cav |