-
Notifications
You must be signed in to change notification settings - Fork 2
100 lines (79 loc) · 3.22 KB
/
auditpulse_app_workflow.yml
File metadata and controls
100 lines (79 loc) · 3.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
name: Auditpulse App Workflow
on:
workflow_dispatch: # Allow manual trigger of the workflow
push:
paths:
- 'ModelPipeline/Backend/**'
jobs:
audit_report_generation_test_and_deploy:
runs-on: ubuntu-latest
env:
# Serper api key
# Agentops api key
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
SERPER_API_KEY: ${{ secrets.SERPER_API_KEY }}
AGENTOPS_API_KEY: ${{ secrets.AGENTOPS_API_KEY }}
MYSQL_GCP_PASS: ${{ secrets.MYSQL_GCP_PASS }}
REGION: us-east1
REPOSITORY_NAME: auditpulse-images
defaults:
run:
working-directory: ModelPipeline/Backend
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set-up Python
uses: actions/setup-python@v4
with:
python-version: 3.12.9
- name: Install Dependencies
run: pip install -r requirements.txt
- name: Authenticate With GCP
uses: 'google-github-actions/auth@v2'
with:
credentials_json: '${{secrets.GOOGLE_APPLICATION_CREDENTIALS}}'
- name: Run Tests
run: python tests/test_audit_report_generation.py
- name: Test Success Notification
if: success()
run: echo "All tests passed. Proceeding to deployment."
- name: Setup GCP CLI
uses: google-github-actions/setup-gcloud@v1
- name: Setup Project ID
run: gcloud config set project ${{secrets.GCP_PROJECT_ID}}
- name: Configure Docker
run: gcloud auth configure-docker ${{env.REGION}}-docker.pkg.dev
- name: Create Timestamp
id: timestamp
run: echo "timestamp=$(date -u +"%Y-%m-%dT%H-%M-%SZ")" >> $GITHUB_ENV
- name: Build & Push Docker Image
run: |
IMAGE_NAME="${{env.REGION}}-docker.pkg.dev/${{secrets.GCP_PROJECT_ID}}/${{env.REPOSITORY_NAME}}/auditpulse-app"
TIMESTAMP="${{env.timestamp}}"
echo "Building Docker image: $IMAGE_NAME"
docker build -t "$IMAGE_NAME:$TIMESTAMP" -t "$IMAGE_NAME:latest" .
docker push "$IMAGE_NAME:$TIMESTAMP"
docker push "$IMAGE_NAME:latest"
- name: Deployment Success Notification
if: success()
run: echo "Docker image for auditpulse app created and pushed."
- name: Deployment Success Email Notification
if: success()
uses: dawidd6/action-send-mail@v3
with:
server_address: smtp.gmail.com
server_port: 587
username: ${{secrets.AH_SMTP_USERNAME}}
password: ${{secrets.AH_SMTP_PASS}}
subject: Auditpulse - New Backend Image Deployed
to: ${{secrets.AH_SMTP_USERNAME}}
from: AuditPulse CI/CD <${{secrets.AH_SMTP_USERNAME}}>
body: |
🎉 A new Docker image for Auditpulse backend has been successfully built and pushed.
✅ Repository: ${{ env.REPOSITORY_NAME }}
✅ Image Tag: ${{ env.timestamp }}
✅ Registry: "${{env.REGION}}-docker.pkg.dev/${{secrets.GCP_PROJECT_ID}}/${{env.REPOSITORY_NAME}}/auditpulse-app"
🕒 Time: ${{ env.timestamp }}
- name: Deployment Failure Notification
if: failure()
run: echo "Deployment failed."