Skip to content

Deploy branch builds #224

Deploy branch builds

Deploy branch builds #224

Workflow file for this run

name: Deploy branch builds
on:
# possible we can deploy on specific branches using prefix and wildcard matches
# e.g. - 'deploy-branch-*'
# https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#example-excluding-branches
push:
branches:
- '!master'
- 'branch-deploy-k8s-setup'
# or we can deploy via dispatch which has a ref (branch / tag) passed to it for checkout actions
# https://docs.github.com/en/rest/actions/workflows#create-a-workflow-dispatch-event
workflow_dispatch:
jobs:
build_and_push_image:
name: Build Image
runs-on: ubuntu-latest
steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v5
with:
push: true
tags: |
ghcr.io/zooniverse/front-end-monorepo-branch:${{ github.sha }}
build-args: |
APP_ENV=branch
COMMIT_ID=${{ github.sha }}
GITHUB_REF_NAME=${{ github.ref_name }}
CONTENTFUL_ACCESS_TOKEN=${{ secrets.CONTENTFUL_ACCESS_TOKEN }}
CONTENTFUL_SPACE_ID=${{ secrets.CONTENTFUL_SPACE_ID }}
SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}
deploy_branch:
runs-on: ubuntu-latest
needs: build_and_push_image
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_AKS }}
- name: Set the target AKS cluster
uses: Azure/aks-set-context@v3
with:
resource-group: kubernetes
cluster-name: microservices
- name: Modify & apply template
run: |
sed 's/__IMAGE_TAG__/${{ github.sha }}/g ; s/__REF_NAME__/${{ github.ref_name }}/g' kubernetes/deployment-branch.tmpl | kubectl apply -f -
slack_notification:
name: Slack notification
uses: zooniverse/ci-cd/.github/workflows/slack_notification.yaml@main
needs: [build_and_push_image, deploy_branch]
if: always()
with:
commit_id: ${{ github.sha }}
job_name: Build Image
status: ${{ needs.build_and_push_image.result }}
title: "FEM branch deploy complete"
title_link: "https://fe-project-branch.preview.zooniverse.org"
secrets:
slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }}