ส่งคัวกลับ
Some checks failed
release-dev / release-dev (push) Failing after 10s

This commit is contained in:
moss 2025-03-28 23:45:36 +07:00
parent 34b8562ffe
commit 18d93995aa
4 changed files with 108 additions and 97 deletions

View file

@ -6,102 +6,102 @@ on:
- "placement-[0-9]+.[0-9]+.[0-9]+" - "placement-[0-9]+.[0-9]+.[0-9]+"
workflow_dispatch: workflow_dispatch:
env: env:
REGISTRY: docker.frappet.com REGISTRY: docker.frappet.com
IMAGE_NAME: ehr/bma-ehr-placement-service IMAGE_NAME: ehr/bma-ehr-placement-service
DEPLOY_HOST: frappet.com DEPLOY_HOST: frappet.com
DEPLOY_PORT: 10102 DEPLOY_PORT: 10102
# COMPOSE_PATH: /home/frappet/docker/bma-ehr # COMPOSE_PATH: /home/frappet/docker/bma-ehr
COMPOSE_PATH: /home/frappet/docker/bma/bma-ehr-placement COMPOSE_PATH: /home/frappet/docker/bma/bma-ehr-placement
TOKEN_LINE: uxuK5hDzS2DsoC5piJBrWRLiz8GgY7iMZZldOWsDDF0 TOKEN_LINE: uxuK5hDzS2DsoC5piJBrWRLiz8GgY7iMZZldOWsDDF0
jobs: jobs:
# act workflow_dispatch -W .github/workflows/release_placement.yaml --input IMAGE_VER=latest -s DOCKER_USER=admin -s DOCKER_PASS=FPTadmin2357 -s SSH_PASSWORD=FPTadmin2357 # act workflow_dispatch -W .github/workflows/release_placement.yaml --input IMAGE_VER=latest -s DOCKER_USER=admin -s DOCKER_PASS=FPTadmin2357 -s SSH_PASSWORD=FPTadmin2357
release-dev: release-dev:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Set output tags - name: Set output tags
id: vars id: vars
run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
- name: Gen Version - name: Gen Version
id: gen_ver id: gen_ver
run: | run: |
if [[ $GITHUB_REF == 'refs/tags/'* ]]; then if [[ $GITHUB_REF == 'refs/tags/'* ]]; then
IMAGE_VER=${{ steps.vars.outputs.tag }} IMAGE_VER=${{ steps.vars.outputs.tag }}
else else
IMAGE_VER=${{ github.event.inputs.IMAGE_VER }} IMAGE_VER=${{ github.event.inputs.IMAGE_VER }}
fi fi
if [[ $IMAGE_VER == '' ]]; then if [[ $IMAGE_VER == '' ]]; then
IMAGE_VER='test-vBeta' IMAGE_VER='test-vBeta'
fi fi
echo '::set-output name=image_ver::'$IMAGE_VER echo '::set-output name=image_ver::'$IMAGE_VER
- name: Check Version - name: Check Version
run: | run: |
echo $GITHUB_REF echo $GITHUB_REF
echo ${{ steps.gen_ver.outputs.image_ver }} echo ${{ steps.gen_ver.outputs.image_ver }}
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2 uses: docker/setup-buildx-action@v2
- name: Login in to registry - name: Login in to registry
uses: docker/login-action@v2 uses: docker/login-action@v2
with: with:
registry: ${{env.REGISTRY}} registry: ${{env.REGISTRY}}
username: ${{secrets.DOCKER_USER}} username: ${{secrets.DOCKER_USER}}
password: ${{secrets.DOCKER_PASS}} password: ${{secrets.DOCKER_PASS}}
- name: Build and load local docker image - name: Build and load local docker image
uses: docker/build-push-action@v3 uses: docker/build-push-action@v3
with: with:
context: . context: .
platforms: linux/amd64 platforms: linux/amd64
file: BMA.EHR.Placement.Service/Dockerfile file: BMA.EHR.Placement.Service/Dockerfile
push: true push: true
tags: ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:${{ steps.gen_ver.outputs.image_ver }},${{env.REGISTRY}}/${{env.IMAGE_NAME}}:latest tags: ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:${{ steps.gen_ver.outputs.image_ver }},${{env.REGISTRY}}/${{env.IMAGE_NAME}}:latest
- name: Reload docker compose - name: Reload docker compose
uses: appleboy/ssh-action@v0.1.8 uses: appleboy/ssh-action@v0.1.8
with: with:
host: ${{env.DEPLOY_HOST}} host: ${{env.DEPLOY_HOST}}
username: frappet username: frappet
password: ${{ secrets.SSH_PASSWORD }} password: ${{ secrets.SSH_PASSWORD }}
port: ${{env.DEPLOY_PORT}} port: ${{env.DEPLOY_PORT}}
script: | script: |
cd "${{env.COMPOSE_PATH}}" cd "${{env.COMPOSE_PATH}}"
docker compose pull docker compose pull
docker compose up -d docker compose up -d
echo "${{ steps.gen_ver.outputs.image_ver }}"> success echo "${{ steps.gen_ver.outputs.image_ver }}"> success
- name: Notify Discord Success # - name: Notify Discord Success
if: success() # if: success()
run: | # run: |
curl -H "Content-Type: application/json" \ # curl -H "Content-Type: application/json" \
-X POST \ # -X POST \
-d '{ # -d '{
"embeds": [{ # "embeds": [{
"title": "✅ Deployment Success!", # "title": "✅ Deployment Success!",
"description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Deployed by: `${{github.actor}}`", # "description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Deployed by: `${{github.actor}}`",
"color": 3066993, # "color": 3066993,
"footer": { # "footer": {
"text": "Release Notification", # "text": "Release Notification",
"icon_url": "https://example.com/success-icon.png" # "icon_url": "https://example.com/success-icon.png"
}, # },
"timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'" # "timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"
}] # }]
}' \ # }' \
${{ secrets.DISCORD_WEBHOOK }} # ${{ secrets.DISCORD_WEBHOOK }}
- name: Notify Discord Failure # - name: Notify Discord Failure
if: failure() # if: failure()
run: | # run: |
curl -H "Content-Type: application/json" \ # curl -H "Content-Type: application/json" \
-X POST \ # -X POST \
-d '{ # -d '{
"embeds": [{ # "embeds": [{
"title": "❌ Deployment Failed!", # "title": "❌ Deployment Failed!",
"description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Attempted by: `${{github.actor}}`", # "description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Attempted by: `${{github.actor}}`",
"color": 15158332, # "color": 15158332,
"footer": { # "footer": {
"text": "Release Notification", # "text": "Release Notification",
"icon_url": "https://example.com/failure-icon.png" # "icon_url": "https://example.com/failure-icon.png"
}, # },
"timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'" # "timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"
}] # }]
}' \ # }' \
${{ secrets.DISCORD_WEBHOOK }} # ${{ secrets.DISCORD_WEBHOOK }}

View file

@ -672,6 +672,7 @@ namespace BMA.EHR.Placement.Service.Controllers
on p.Id.ToString() equals r.refId on p.Id.ToString() equals r.refId
select new select new
{ {
refId = p.Id,
profileId = p.profileId, profileId = p.profileId,
amount = r.amount, amount = r.amount,
amountSpecial = r.amountSpecial, amountSpecial = r.amountSpecial,

View file

@ -221,10 +221,18 @@ namespace BMA.EHR.Placement.Service.Controllers
[HttpPost()] [HttpPost()]
public async Task<ActionResult<ResponseObject>> Post([FromForm] PlacementAddProfileRequest req) public async Task<ActionResult<ResponseObject>> Post([FromForm] PlacementAddProfileRequest req)
{ {
var placementOfficer = await _context.PlacementOfficers
.Where(x => x.Id == (req.OfficerId ?? Guid.Parse("00000000-0000-0000-0000-000000000000")))
.FirstOrDefaultAsync();
if (placementOfficer == null)
return Error("ไม่พบรายการช่วยราชการ", 404);
var placementRepatriation = new PlacementRepatriation var placementRepatriation = new PlacementRepatriation
{ {
Organization = Request.Form.ContainsKey("Organization") ? Request.Form["Organization"] : "", Organization = placementOfficer.Organization,
Reason = Request.Form.ContainsKey("Reason") ? Request.Form["Reason"] : "", // Reason = placementOfficer.Reason,
Date = placementOfficer.DateStart,
DateRepatriation = placementOfficer.DateEnd,
Status = "WAITTING", Status = "WAITTING",
CreatedFullName = FullName ?? "System Administrator", CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "", CreatedUserId = UserId ?? "",
@ -507,6 +515,7 @@ namespace BMA.EHR.Placement.Service.Controllers
on p.Id.ToString() equals r.refId on p.Id.ToString() equals r.refId
select new select new
{ {
refId = p.Id,
profileId = p.profileId, profileId = p.profileId,
amount = r.amount, amount = r.amount,
amountSpecial = r.amountSpecial, amountSpecial = r.amountSpecial,

View file

@ -6,5 +6,6 @@ namespace BMA.EHR.Placement.Service.Requests
public class PlacementAddProfileRequest public class PlacementAddProfileRequest
{ {
public Guid Id { get; set; } public Guid Id { get; set; }
public Guid? OfficerId { get; set; }
} }
} }