Skip to content

Build -> Test -> Deploy #292

Build -> Test -> Deploy

Build -> Test -> Deploy #292

name: Build -> Test -> Deploy
on:
push:
branches:
- master
tags:
- 'prod-*'
schedule:
- cron: '0 6 * * *'
env:
RELEASE_VERSION: ${{ github.sha }}
jobs:
build:
# runs-on: buildjet-2vcpu-ubuntu-2004
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build Image
run: ./scripts/build-release.sh
- name: Authenticate to DO Container Registry
env:
DOCKER_CONFIG: ${{ secrets.DOCKER_CONFIG }}
run: |
mkdir -p $HOME/.docker
echo "${DOCKER_CONFIG}" > $HOME/.docker/config.json
- name: Push Image
run: ./scripts/push-release.sh
test:
needs: [build]
# runs-on: buildjet-2vcpu-ubuntu-2004
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Test
run: ./scripts/run-ci.sh
deploy-staging:
needs: [build, test]
# runs-on: buildjet-2vcpu-ubuntu-2004
runs-on: ubuntu-latest
#if: ${{ endsWith(github.ref, 'main') || endsWith(github.ref, '') }}
env:
ENV: staging
K8S_SERVER: ${{ secrets.K8S_ENDPOINT_STAGING }}
K8S_TOKEN: ${{ secrets.K8S_TOKEN_STAGING }}
K8S_CA_CERT: ${{ secrets.K8S_CA_CERT_STAGING }}
SLACK_CHANNEL: '#connect-bots'
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
HOSTNAME: 'cvh-staging'
DOMAIN: 'ameelio.xyz'
ZONE_ID: '16c266b9ad2cc7affc86783eb0fa74fd'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Render Manifests
run: ./scripts/deploy-release.sh --save-deploy --manifest-dir "manifests-${RELEASE_VERSION}-${ENV}" --debug
- name: Archive Rendered Kubernetes Manifests
uses: actions/upload-artifact@v1
with:
name: "manifests-${{ env.RELEASE_VERSION }}-${{ env.ENV }}"
path: "manifests-${{ env.RELEASE_VERSION }}-${{ env.ENV }}"
#- name: Run migrations
# env:
# K8S_TOKEN: ${{ secrets.K8S_TOKEN_STAGING }}
# SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
# run: ./scripts/deploy-release.sh --apply-migration --manifest-dir "manifests-${RELEASE_VERSION}-${ENV}" --debug
- name: Deploy new version
env:
K8S_TOKEN: ${{ secrets.K8S_TOKEN_STAGING }}
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
run: ./scripts/deploy-release.sh --apply-deploy --manifest-dir "manifests-${RELEASE_VERSION}-${ENV}" --debug
deploy-prod:
needs: [build, test, deploy-staging]
# runs-on: buildjet-2vcpu-ubuntu-2004
runs-on: ubuntu-latest
if: ${{ startsWith(github.ref, 'refs/tags/prod-') }}
env:
ENV: prod
K8S_SERVER: ${{ secrets.K8S_ENDPOINT_PROD }}
K8S_TOKEN: ${{ secrets.K8S_TOKEN_PROD }}
K8S_CA_CERT: ${{ secrets.K8S_CA_CERT_PROD }}
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
SLACK_CHANNEL: '#infa-info'
HOSTNAME: 'cvh-prod'
DOMAIN: 'ameelio.org'
ZONE_ID: 'c82786df7abd35eb6773c67960fba8d3'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Render Manifests
run: ./scripts/deploy-release.sh --save-deploy --manifest-dir "manifests-${RELEASE_VERSION}-${ENV}" --debug
- name: Archive Rendered Kubernetes Manifests
uses: actions/upload-artifact@v1
with:
name: "manifests-${{ env.RELEASE_VERSION }}-${{ env.ENV }}"
path: "manifests-${{ env.RELEASE_VERSION }}-${{ env.ENV }}"
#- name: Run migrations
# env:
# K8S_TOKEN: ${{ secrets.K8S_TOKEN_PROD }}
# SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
# run: ./scripts/deploy-release.sh --apply-migration --manifest-dir "manifests-${RELEASE_VERSION}-${ENV}" --debug
- name: Deploy new version
run: ./scripts/deploy-release.sh --apply-deploy --manifest-dir "manifests-${RELEASE_VERSION}-${ENV}" --debug
deploy-mcc:
needs: [build, test, deploy-staging]
# runs-on: buildjet-2vcpu-ubuntu-2004
runs-on: ubuntu-latest
if: ${{ startsWith(github.ref, 'refs/tags/prod-') }}
env:
ENV: prod
K8S_SERVER: ${{ secrets.K8S_ENDPOINT_MCC }}
K8S_TOKEN: ${{ secrets.K8S_TOKEN_MCC }}
K8S_CA_CERT: ${{ secrets.K8S_CA_CERT_MCC }}
SLACK_CHANNEL: '#infra-info'
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
FACILITY: MCC
HOSTNAME: 'cvh-mcc'
DOMAIN: 'ameelio.org'
ZONE_ID: 'c82786df7abd35eb6773c67960fba8d3'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Render Manifests
run: ./scripts/deploy-release.sh --save-deploy --manifest-dir "manifests-${RELEASE_VERSION}-${ENV}" --debug
- name: Archive Rendered Kubernetes Manifests
uses: actions/upload-artifact@v1
with:
name: "manifests-${{ env.RELEASE_VERSION }}-${{ env.ENV }}"
path: "manifests-${{ env.RELEASE_VERSION }}-${{ env.ENV }}"
- name: Deploy new version
run: ./scripts/deploy-release.sh --apply-deploy --manifest-dir "manifests-${RELEASE_VERSION}-${ENV}" --debug