Skip to content

Commit

Permalink
Merge pull request #1 from zooniverse/gha-deploy
Browse files Browse the repository at this point in the history
Build/Run/Deploy with GHA
  • Loading branch information
zwolf authored Jan 31, 2024
2 parents 8ce1223 + 968ea54 commit 7c1ecb1
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 1 deletion.
43 changes: 43 additions & 0 deletions .github/workflows/cron_deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Deploy Hotmail Processing Cron Task

on:
push:
branches:
- master
workflow_dispatch:

jobs:
build_and_push_image:
name: Build and Push Image
uses: zooniverse/ci-cd/.github/workflows/build_and_push_image.yaml@main
with:
repo_name: hotmail-complaint-processor
commit_id: ${{ github.sha }}
latest: true

deploy_cron:
runs-on: ubuntu-latest
needs: build_and_push_image
steps:
- name: Checkout
uses: actions/checkout@v3.5.2

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_AKS }}

- name: Set the target AKS cluster
uses: Azure/aks-set-context@v3
with:
cluster-name: microservices
resource-group: kubernetes

- name: Modify & apply template
run: kubectl create -f kubernetes/cron_script.yml
31 changes: 31 additions & 0 deletions .github/workflows/manual_run.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Manually Run Hotmail Complaint Processing

on:
workflow_dispatch:

jobs:
manual_sync:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3.5.2

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_AKS }}

- name: Set the target AKS cluster
uses: Azure/aks-set-context@v3
with:
cluster-name: microservices
resource-group: kubernetes

- name: Modify & apply template
run: kubectl create -f kubernetes/manual_script.yml
33 changes: 33 additions & 0 deletions kubernetes/cron_script.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: batch/v1
kind: CronJob
metadata:
name: hotmail-complaint-processor-cronjob
spec:
schedule: "0 * * * *"
jobTemplate:
spec:
template:
metadata:
name: hotmail-complaint-processor-cronjob
spec:
containers:
- name: hotmail-complaint-processor-cronjob
image: ghcr.io/zooniverse/hotmail-complaint-processor
volumeMounts:
- name: hotmail-complaint-config
mountPath: "/run/secrets/config.yml"
subPath: "config.yml"
readOnly: true
- name: hotmail-aws-creds
mountPath: "/root/.aws/credentials"
subPath: "credentials"
readOnly: true
volumes:
- name: hotmail-complaint-config
secret:
secretName: hotmail-complaint-config
- name: hotmail-aws-creds
secret:
secretName: hotmail-aws-creds
restartPolicy: Never
backoffLimit: 2
30 changes: 30 additions & 0 deletions kubernetes/manual_script.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
apiVersion: batch/v1
kind: Job
metadata:
generateName: hotmail-complaint-processor-job-
spec:
template:
metadata:
name: hotmail-complaint-processor-job
spec:
containers:
- name: hotmail-complaint-processor-job
image: ghcr.io/zooniverse/hotmail-complaint-processor
volumeMounts:
- name: hotmail-complaint-config
mountPath: "/run/secrets/config.yml"
subPath: "config.yml"
readOnly: true
- name: hotmail-aws-creds
mountPath: "/root/.aws/credentials"
subPath: "credentials"
readOnly: true
volumes:
- name: hotmail-complaint-config
secret:
secretName: hotmail-complaint-config
- name: hotmail-aws-creds
secret:
secretName: hotmail-aws-creds
restartPolicy: Never
backoffLimit: 2
3 changes: 2 additions & 1 deletion process.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
with open('/run/secrets/config.yml', 'r') as f:
CONFIG = yaml.load(f)

s3 = boto3.resource('s3')
session = boto3.Session(profile_name='default')
s3 = session.resource('s3')

addresses_to_unsubscribe = set()
processed_s3_keys = []
Expand Down

0 comments on commit 7c1ecb1

Please sign in to comment.