forked from horilla-opensource/horilla
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2763591
commit fb81c7d
Showing
13 changed files
with
223 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
{ | ||
"taskDefinitionArn": "arn:aws:ecs:ap-south-1:732163342771:task-definition/EMS-Prod:47", | ||
"containerDefinitions": [ | ||
{ | ||
"name": "HRMS", | ||
"image": "732163342771.dkr.ecr.ap-south-1.amazonaws.com/ems-horilla-prod:d67723699f7ec03e48621578222c4533ba55a655", | ||
"cpu": 0, | ||
"portMappings": [ | ||
{ | ||
"name": "primary-port", | ||
"containerPort": 8000, | ||
"hostPort": 8000, | ||
"protocol": "tcp", | ||
"appProtocol": "http" | ||
} | ||
], | ||
"essential": true, | ||
"environment": [], | ||
"environmentFiles": [ | ||
{ | ||
"value": "arn:aws:s3:::ems-env-prod/.env", | ||
"type": "s3" | ||
} | ||
], | ||
"mountPoints": [ | ||
{ | ||
"sourceVolume": "ems-media", | ||
"containerPath": "/ems/media", | ||
"readOnly": false | ||
} | ||
], | ||
"volumesFrom": [], | ||
"logConfiguration": { | ||
"logDriver": "awslogs", | ||
"options": { | ||
"awslogs-create-group": "true", | ||
"awslogs-group": "/ecs/EMS-Prod", | ||
"awslogs-region": "ap-south-1", | ||
"awslogs-stream-prefix": "ecs" | ||
}, | ||
"secretOptions": [] | ||
} | ||
} | ||
], | ||
"family": "EMS-Prod", | ||
"executionRoleArn": "arn:aws:iam::732163342771:role/ecsTaskExecutionRole", | ||
"networkMode": "bridge", | ||
"revision": 47, | ||
"volumes": [ | ||
{ | ||
"name": "ems-media", | ||
"dockerVolumeConfiguration": { | ||
"scope": "shared", | ||
"autoprovision": false, | ||
"driver": "local" | ||
} | ||
} | ||
], | ||
"status": "ACTIVE", | ||
"requiresAttributes": [ | ||
{ | ||
"name": "com.amazonaws.ecs.capability.logging-driver.awslogs" | ||
}, | ||
{ | ||
"name": "ecs.capability.execution-role-awslogs" | ||
}, | ||
{ | ||
"name": "com.amazonaws.ecs.capability.ecr-auth" | ||
}, | ||
{ | ||
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.19" | ||
}, | ||
{ | ||
"name": "ecs.capability.env-files.s3" | ||
}, | ||
{ | ||
"name": "ecs.capability.docker-plugin.local" | ||
}, | ||
{ | ||
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.25" | ||
}, | ||
{ | ||
"name": "ecs.capability.execution-role-ecr-pull" | ||
}, | ||
{ | ||
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.29" | ||
} | ||
], | ||
"placementConstraints": [], | ||
"compatibilities": [ | ||
"EC2" | ||
], | ||
"requiresCompatibilities": [ | ||
"EC2" | ||
], | ||
"cpu": "256", | ||
"memory": "256", | ||
"runtimePlatform": { | ||
"cpuArchitecture": "X86_64", | ||
"operatingSystemFamily": "LINUX" | ||
}, | ||
"registeredAt": "2024-02-27T05:13:10.313Z", | ||
"registeredBy": "arn:aws:iam::732163342771:root", | ||
"tags": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: Deploy to Production Network | ||
|
||
on: | ||
push: | ||
branches: | ||
- Production | ||
workflow_dispatch: | ||
|
||
jobs: | ||
Deploy: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws-region: ap-south-1 | ||
|
||
- name: Login to Amazon ECR | ||
id: login-ecr | ||
uses: aws-actions/amazon-ecr-login@v2 | ||
|
||
- name: Build, tag, and push image to Amazon ECR | ||
id: build-image | ||
env: | ||
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | ||
ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY }} | ||
IMAGE_TAG: ${{ github.sha }} | ||
run: | | ||
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . | ||
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | ||
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT | ||
- name: Update New Image ID in ECS Task Definition | ||
id: task-def | ||
uses: aws-actions/amazon-ecs-render-task-definition@v1 | ||
with: | ||
task-definition: ./.github/workflows/prod-deploy-task.json | ||
container-name: HRMS | ||
image: ${{ steps.build-image.outputs.image }} | ||
|
||
- name: Stop All tasks on ECS Cluster | ||
continue-on-error: true | ||
run: aws ecs stop-task --cluster "EmsProd" --task $(aws ecs list-tasks --cluster "EmsProd" --service "HRMS-Prod" --output text --query taskArns[0]) | ||
|
||
- name: Deploy Amazon ECS task definition | ||
uses: aws-actions/amazon-ecs-deploy-task-definition@v1 | ||
with: | ||
task-definition: ${{ steps.task-def.outputs.task-definition }} | ||
service: HRMS-Prod | ||
cluster: EmsProd | ||
wait-for-service-stability: false | ||
force-new-deployment: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import handlers | ||
default_app_config = 'webhook_handler.apps.WebhookHandlerConfig' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.contrib import admin | ||
|
||
# Register your models here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# webhook_handler/apps.py | ||
from django.apps import AppConfig | ||
|
||
class WebhookHandlerConfig(AppConfig): | ||
default_auto_field = 'django.db.models.BigAutoField' | ||
name = 'webhook_handler' | ||
|
||
def ready(self): | ||
import webhook_handler.handlers # noqa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# webhook_handler/handlers.py | ||
from django.dispatch import receiver | ||
from django.db.models.signals import post_save | ||
import requests | ||
import json | ||
import os | ||
|
||
@receiver(post_save) | ||
# Webhook triggered when a new candidate is created | ||
def handle_model_update(sender, created, instance, **kwargs): | ||
if sender.__name__ == 'Candidate' and created: | ||
# send a request to the webhook | ||
url = os.environ.get("WEBHOOK_URL_NEW_CANDIDATE") | ||
data = { | ||
"username": 'Oxlac HRMS', | ||
"avatar_url": "https://oxlac.com/favicon.png", | ||
"embeds": [ | ||
{ | ||
"author": { | ||
"name": "Oxlac HRMS", | ||
"url": "https://oxlac.com", | ||
"icon_url": "https://oxlac.com/favicon.png" | ||
}, | ||
"title": "New Candidate has applied for position " + str(instance.job_position_id), | ||
"url": "https://employee.oxlac.com/candidate-view/" + str(instance.recruitment_id)+"/", | ||
"description": "Candidate Name: " + instance.name + "\n" + "Email: " + instance.email, | ||
} | ||
] | ||
} | ||
# send the request | ||
requests.post(url, data=json.dumps(data), headers={"Content-Type": "application/json"}) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.db import models | ||
|
||
# Create your models here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.shortcuts import render | ||
|
||
# Create your views here. |