Merge pull request #15 from zooniverse/mdv5-zooniverse-poc #2
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: Deploy to Production | |
on: | |
push: | |
branches: | |
- zooniverse-deployment | |
workflow_dispatch: | |
jobs: | |
build_and_push_image: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/[email protected] | |
with: | |
repository: zooniverse/camera-traps-api | |
ref: zooniverse-deployment | |
- name: Login to GitHub Container Registry | |
uses: docker/[email protected] | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Docker Buildx | |
uses: docker/[email protected] | |
- name: Create commit_id.txt | |
run: echo ${{ github.sha }} > commit_id.txt | |
- name: Build and push | |
uses: docker/[email protected] | |
with: | |
context: . | |
file: ./api/batch_processing/api_core/Dockerfile | |
push: true | |
tags: | | |
ghcr.io/zooniverse/camera-traps-api:latest | |
ghcr.io/zooniverse/camera-traps-api:${{ github.sha }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
deploy_app: | |
runs-on: ubuntu-latest | |
needs: [build_and_push_image] | |
steps: | |
- name: Checkout | |
uses: actions/[email protected] | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- uses: azure/login@v1 | |
with: | |
creds: ${{ secrets.AZURE_AKS }} | |
- uses: azure/aks-set-context@v3 | |
with: | |
resource-group: kubernetes | |
cluster-name: microservices | |
- name: Dry run deployments | |
run: | | |
sed "s/__IMAGE_TAG__/${{ github.sha }}/g" ./api/batch_processing/api_core/kubernetes/deployment.tmpl \ | |
| kubectl --context azure apply --dry-run=client --record -f - | |
- name: Modify & apply template | |
run: | | |
sed "s/__IMAGE_TAG__/${{ github.sha }}/g" ./api/batch_processing/api_core/kubernetes/deployment.tmpl \ | |
| kubectl --context azure apply --record -f - | |