Skip to content

Merge pull request #883 from NoodleOfDeath/dev #1106

Merge pull request #883 from NoodleOfDeath/dev

Merge pull request #883 from NoodleOfDeath/dev #1106

Workflow file for this run

name: Scheduler CI
on:
push:
branches:
- main
- dev
concurrency:
group: ${{ github.ref }}-scheduler
cancel-in-progress: true
env:
IMAGE: ${{ github.event.repository.name }}-scheduler-${{ fromJSON('{"main":"prod"}')[github.ref_name] || github.ref_name }}
REGISTRY: ${{ vars.REGISTRY }}
jobs:
build-scheduler:
runs-on: ubuntu-latest
if: ${{ contains(github.event.head_commit.message, '~scheduler') || contains(github.event.head_commit.message, '~deploy') }}
environment: ${{ fromJSON('{"main":"prod"}')[github.ref_name] || github.ref_name }}
steps:
- name: Print Job Description
run: |
echo building \"$IMAGE\" from branch \"${{ github.ref_name }}\"
- name: Git Checkout
uses: actions/checkout@v3
with:
ssh-key: ${{ secrets.GIT_SSH_KEY }}
submodules: recursive
- name: Build
run: |
docker build . --file Dockerfile.scheduler --tag $IMAGE:latest
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- name: Log in to doctl
run: doctl registry login --expiry-seconds 600
- name: Tag Docker Image
run: docker tag $IMAGE:latest $REGISTRY/$IMAGE:latest
- name: Push Docker Image
run: docker push $REGISTRY/$IMAGE:latest
deploy-scheduler:
needs: build-scheduler
runs-on: ubuntu-latest
environment: ${{ fromJSON('{"main":"prod"}')[github.ref_name] || github.ref_name }}
env:
API_ENDPOINT: ${{ vars.API_ENDPOINT }}
CACHE_LIFESPAN: ${{ vars.CACHE_LIFESPAN }}
CHROMIUM_EXECUTABLE_PATH: ${{ vars.CHROMIUM_EXECUTABLE_PATH }}
ENABLED_FEATURES: ${{ vars.ENABLED_FEATURES }}
K8S_NAMESPACE: ${{ secrets.K8S_NAMESPACE }}
K8S_MEMORY_REQUESTS: ${{ vars.K8S_MEMORY_REQUESTS }}
K8S_CPU_REQUESTS: ${{ vars.K8S_CPU_REQUESTS }}
K8S_MEMORY_LIMITS: ${{ vars.K8S_MEMORY_LIMITS }}
K8S_CPU_LIMITS: ${{ vars.K8S_CPU_LIMITS }}
K8S_REPLICA_COUNT_SCHEDULER: ${{ vars.K8S_REPLICA_COUNT_SCHEDULER }}
OLD_NEWS_THRESHOLD: ${{ vars.OLD_NEWS_THRESHOLD }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
PG_CONNECTION_STRING: ${{ secrets.PG_CONNECTION_STRING }}
PUBLISHER_MAX_ATTEMPT_LIMIT: ${{ vars.PUBLISHER_MAX_ATTEMPT_LIMIT }}
SPIDER_FETCH_INTERVAL: ${{ vars.SPIDER_FETCH_INTERVAL }}
TOPIC_RECALCULATE_RATE: ${{ vars.TOPIC_RECALCULATE_RATE }}
steps:
- name: Print Job Description
run: |
echo deploying \"$IMAGE\" from branch \"${{ github.ref_name }}\"
- name: Git Checkout
uses: actions/checkout@v3
with:
ssh-key: ${{ secrets.GIT_SSH_KEY }}
submodules: recursive
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- name: Add kubectl cert
run: doctl kubernetes cluster kubeconfig save --expiry-seconds 600 ${{ secrets.K8S_CLUSTER_ID }}
- name: Apply deployment changes
run: envsubst < $GITHUB_WORKSPACE/k8s/scheduler-deploy.yaml | kubectl apply -f -
- name: Deploy Rollout
run: kubectl rollout restart deployment/$IMAGE --namespace $K8S_NAMESPACE
- name: Verify deployment
run: kubectl rollout status deployment/$IMAGE --namespace $K8S_NAMESPACE