diff --git a/.forgejo/workflows/build-checkin.yml b/.forgejo/workflows/build-checkin.yml new file mode 100644 index 00000000..3971e9df --- /dev/null +++ b/.forgejo/workflows/build-checkin.yml @@ -0,0 +1,83 @@ +name: Build & Deploy Checkin Service + +on: + push: + tags: + - "checkin-dev[0-9]+.[0-9]+.[0-9]+" + - "checkin-dev[0-9]+.[0-9]+.[0-9]+*" + workflow_dispatch: + +env: + REGISTRY: ${{ vars.CONTAINER_REGISTRY }} + REGISTRY_USERNAME: ${{ vars.CONTAINER_REGISTRY_USERNAME }} + REGISTRY_PASSWORD: ${{ secrets.CONTAINER_REGISTRY_PASSWORD }} + CONTAINER_IMAGE_NAME: ${{ vars.CONTAINER_REGISTRY }}/${{ vars.CONTAINER_IMAGE_OWNER }} + IMAGE_VERSION: latest + SERVICE_NAME: hrms-api-checkin + DISCORD_WEBHOOK: ${{ vars.DISCORD_WEBHOOK }} + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Tag Version + shell: bash + run: | + if [[ "${{ github.event_name }}" == "push" ]]; then + VERSION=$(echo "${{ github.ref_name }}" | sed 's/checkin-dev//g') + echo "IMAGE_VERSION=${VERSION}" >> $GITHUB_ENV + else + echo "IMAGE_VERSION=${{ env.IMAGE_VERSION }}-${{ github.run_number }}" >> $GITHUB_ENV + fi + - name: Login in to registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ env.REGISTRY_USERNAME }} + password: ${{ env.REGISTRY_PASSWORD }} + + - name: Build and push docker image + uses: docker/build-push-action@v5 + with: + platforms: linux/amd64 + context: . + file: ./BMA.EHR.CheckInConsumer/Dockerfile + tags: ${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}:latest,${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}:${{ env.IMAGE_VERSION }} + push: true + + - name: Remote Deploy + uses: appleboy/ssh-action@v1.2.1 + with: + host: ${{ vars.SSH_DEPLOY_HOST }} + port: ${{ vars.SSH_DEPLOY_PORT }} + username: ${{ secrets.SSH_DEPLOY_USER }} + password: ${{ secrets.SSH_DEPLOY_PASSWORD }} + script: | + cd ~/repo + ./replace-env.sh API_CHECKIN "${{ env.IMAGE_VERSION }}" + ./deploy.sh ${{ env.SERVICE_NAME }} + + - name: Discord Notification + if: always() + run: | + STATUS="${{ job.status == 'success' && '✅ Success' || '❌ Failed' }}" + COLOR="${{ job.status == 'success' && '3066993' || '15158332' }}" + TIMESTAMP=$(date -u +%Y-%m-%dT%H:%M:%SZ) + curl -H "Content-Type: application/json" \ + -X POST \ + -d "{ + \"embeds\": [{ + \"title\": \"$STATUS\", + \"description\": \"**Build & Deploy**\\n- Image: \`${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}\`\\n- Version: \`${{ env.IMAGE_VERSION }}\`\\n- By: \`${{ gitea.actor }}\`\", + \"color\": $COLOR, + \"footer\": { + \"text\": \"Release Notification\", + \"icon_url\": \"https://example.com/success-icon.png\" + }, + \"timestamp\": \"$TIMESTAMP\" + }] + }" \ + ${{ env.DISCORD_WEBHOOK }} diff --git a/.forgejo/workflows/build-command_backup.yml b/.forgejo/workflows/build-command_backup.yml new file mode 100644 index 00000000..0884c70b --- /dev/null +++ b/.forgejo/workflows/build-command_backup.yml @@ -0,0 +1,61 @@ +# name: Build + +# on: +# push: +# tags: +# - "command-dev[0-9]+.[0-9]+.[0-9]+" +# - "command-dev[0-9]+.[0-9]+.[0-9]+*" +# workflow_dispatch: + +# env: +# REGISTRY: ${{ vars.CONTAINER_REGISTRY }} +# REGISTRY_USERNAME: ${{ vars.CONTAINER_REGISTRY_USERNAME }} +# REGISTRY_PASSWORD: ${{ secrets.CONTAINER_REGISTRY_PASSWORD }} +# CONTAINER_IMAGE_NAME: ${{ vars.CONTAINER_REGISTRY }}/${{ vars.CONTAINER_IMAGE_OWNER }} +# IMAGE_VERSION: build +# DISCORD_WEBHOOK: ${{ vars.DISCORD_WEBHOOK }} + +# jobs: +# build: +# runs-on: ubuntu-latest +# steps: +# - name: Checkout repository +# uses: actions/checkout@v4 +# - name: Set up Docker Buildx +# uses: docker/setup-buildx-action@v2 +# with: +# config-inline: | +# [registry."${{ env.REGISTRY }}"] +# ca=["/etc/ssl/certs/ca-certificates.crt"] +# - name: Tag Version +# run: | +# if [[ "${{ github.event_name }}" == "push" ]]; then +# echo "IMAGE_VERSION=${{ github.ref_name }}" | sed 's/command-dev//g' >> $GITHUB_ENV +# else +# echo "IMAGE_VERSION=${{ env.IMAGE_VERSION }}-${{ github.run_number }}" >> $GITHUB_ENV +# fi +# - name: Login in to registry +# uses: docker/login-action@v2 +# with: +# registry: ${{ env.REGISTRY }} +# username: ${{ env.REGISTRY_USERNAME }} +# password: ${{ env.REGISTRY_PASSWORD }} +# - name: Build and push docker image +# uses: docker/build-push-action@v3 +# with: +# platforms: linux/amd64 +# context: . +# file: ./BMA.EHR.Command.Service/Dockerfile +# tags: ${{ env.CONTAINER_IMAGE_NAME }}/hrms-api-command:latest,${{ env.CONTAINER_IMAGE_NAME }}/hrms-api-command:${{ env.IMAGE_VERSION }} +# push: true +# - name: Remote Deploy +# uses: appleboy/ssh-action@v1.2.1 +# with: +# host: ${{ vars.SSH_DEPLOY_HOST }} +# port: ${{ vars.SSH_DEPLOY_PORT }} +# username: ${{ secrets.SSH_DEPLOY_USER }} +# password: ${{ secrets.SSH_DEPLOY_PASSWORD }} +# script: | +# cd ~/repo +# ./replace-env.sh API_COMMAND "${{ env.IMAGE_VERSION }}" +# ./deploy.sh hrms-api-command diff --git a/.forgejo/workflows/build-discipline.yml b/.forgejo/workflows/build-discipline.yml new file mode 100644 index 00000000..767d775b --- /dev/null +++ b/.forgejo/workflows/build-discipline.yml @@ -0,0 +1,83 @@ +name: Build & Deploy Discipline Service + +on: + push: + tags: + - "discipline-dev[0-9]+.[0-9]+.[0-9]+" + - "discipline-dev[0-9]+.[0-9]+.[0-9]+*" + workflow_dispatch: + +env: + REGISTRY: ${{ vars.CONTAINER_REGISTRY }} + REGISTRY_USERNAME: ${{ vars.CONTAINER_REGISTRY_USERNAME }} + REGISTRY_PASSWORD: ${{ secrets.CONTAINER_REGISTRY_PASSWORD }} + CONTAINER_IMAGE_NAME: ${{ vars.CONTAINER_REGISTRY }}/${{ vars.CONTAINER_IMAGE_OWNER }} + IMAGE_VERSION: latest + SERVICE_NAME: hrms-api-discipline + DISCORD_WEBHOOK: ${{ vars.DISCORD_WEBHOOK }} + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Tag Version + shell: bash + run: | + if [[ "${{ github.event_name }}" == "push" ]]; then + VERSION=$(echo "${{ github.ref_name }}" | sed 's/discipline-dev//g') + echo "IMAGE_VERSION=${VERSION}" >> $GITHUB_ENV + else + echo "IMAGE_VERSION=${{ env.IMAGE_VERSION }}-${{ github.run_number }}" >> $GITHUB_ENV + fi + - name: Login in to registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ env.REGISTRY_USERNAME }} + password: ${{ env.REGISTRY_PASSWORD }} + + - name: Build and push docker image + uses: docker/build-push-action@v5 + with: + platforms: linux/amd64 + context: . + file: ./BMA.EHR.Discipline.Service/Dockerfile + tags: ${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}:latest,${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}:${{ env.IMAGE_VERSION }} + push: true + + - name: Remote Deploy + uses: appleboy/ssh-action@v1.2.1 + with: + host: ${{ vars.SSH_DEPLOY_HOST }} + port: ${{ vars.SSH_DEPLOY_PORT }} + username: ${{ secrets.SSH_DEPLOY_USER }} + password: ${{ secrets.SSH_DEPLOY_PASSWORD }} + script: | + cd ~/repo + ./replace-env.sh API_DISCIPLINE "${{ env.IMAGE_VERSION }}" + ./deploy.sh ${{ env.SERVICE_NAME }} + + - name: Discord Notification + if: always() + run: | + STATUS="${{ job.status == 'success' && '✅ Success' || '❌ Failed' }}" + COLOR="${{ job.status == 'success' && '3066993' || '15158332' }}" + TIMESTAMP=$(date -u +%Y-%m-%dT%H:%M:%SZ) + curl -H "Content-Type: application/json" \ + -X POST \ + -d "{ + \"embeds\": [{ + \"title\": \"$STATUS\", + \"description\": \"**Build & Deploy**\\n- Image: \`${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}\`\\n- Version: \`${{ env.IMAGE_VERSION }}\`\\n- By: \`${{ gitea.actor }}\`\", + \"color\": $COLOR, + \"footer\": { + \"text\": \"Release Notification\", + \"icon_url\": \"https://example.com/success-icon.png\" + }, + \"timestamp\": \"$TIMESTAMP\" + }] + }" \ + ${{ env.DISCORD_WEBHOOK }} diff --git a/.forgejo/workflows/build-insignia.yml b/.forgejo/workflows/build-insignia.yml new file mode 100644 index 00000000..7ddcbdbd --- /dev/null +++ b/.forgejo/workflows/build-insignia.yml @@ -0,0 +1,83 @@ +name: Build & Deploy Insignia Service + +on: + push: + tags: + - "insignia-dev[0-9]+.[0-9]+.[0-9]+" + - "insignia-dev[0-9]+.[0-9]+.[0-9]+*" + workflow_dispatch: + +env: + REGISTRY: ${{ vars.CONTAINER_REGISTRY }} + REGISTRY_USERNAME: ${{ vars.CONTAINER_REGISTRY_USERNAME }} + REGISTRY_PASSWORD: ${{ secrets.CONTAINER_REGISTRY_PASSWORD }} + CONTAINER_IMAGE_NAME: ${{ vars.CONTAINER_REGISTRY }}/${{ vars.CONTAINER_IMAGE_OWNER }} + IMAGE_VERSION: latest + SERVICE_NAME: hrms-api-insignia + DISCORD_WEBHOOK: ${{ vars.DISCORD_WEBHOOK }} + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Tag Version + shell: bash + run: | + if [[ "${{ github.event_name }}" == "push" ]]; then + VERSION=$(echo "${{ github.ref_name }}" | sed 's/insignia-dev//g') + echo "IMAGE_VERSION=${VERSION}" >> $GITHUB_ENV + else + echo "IMAGE_VERSION=${{ env.IMAGE_VERSION }}-${{ github.run_number }}" >> $GITHUB_ENV + fi + - name: Login in to registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ env.REGISTRY_USERNAME }} + password: ${{ env.REGISTRY_PASSWORD }} + + - name: Build and push docker image + uses: docker/build-push-action@v5 + with: + platforms: linux/amd64 + context: . + file: ./BMA.EHR.Insignia/Dockerfile + tags: ${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}:latest,${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}:${{ env.IMAGE_VERSION }} + push: true + + - name: Remote Deploy + uses: appleboy/ssh-action@v1.2.1 + with: + host: ${{ vars.SSH_DEPLOY_HOST }} + port: ${{ vars.SSH_DEPLOY_PORT }} + username: ${{ secrets.SSH_DEPLOY_USER }} + password: ${{ secrets.SSH_DEPLOY_PASSWORD }} + script: | + cd ~/repo + ./replace-env.sh API_INSIGNIA "${{ env.IMAGE_VERSION }}" + ./deploy.sh ${{ env.SERVICE_NAME }} + + - name: Discord Notification + if: always() + run: | + STATUS="${{ job.status == 'success' && '✅ Success' || '❌ Failed' }}" + COLOR="${{ job.status == 'success' && '3066993' || '15158332' }}" + TIMESTAMP=$(date -u +%Y-%m-%dT%H:%M:%SZ) + curl -H "Content-Type: application/json" \ + -X POST \ + -d "{ + \"embeds\": [{ + \"title\": \"$STATUS\", + \"description\": \"**Build & Deploy**\\n- Image: \`${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}\`\\n- Version: \`${{ env.IMAGE_VERSION }}\`\\n- By: \`${{ gitea.actor }}\`\", + \"color\": $COLOR, + \"footer\": { + \"text\": \"Release Notification\", + \"icon_url\": \"https://example.com/success-icon.png\" + }, + \"timestamp\": \"$TIMESTAMP\" + }] + }" \ + ${{ env.DISCORD_WEBHOOK }} diff --git a/.forgejo/workflows/build-leave.yml b/.forgejo/workflows/build-leave.yml new file mode 100644 index 00000000..b1c9c168 --- /dev/null +++ b/.forgejo/workflows/build-leave.yml @@ -0,0 +1,83 @@ +name: Build & Deploy Leave Service + +on: + push: + tags: + - "leave-dev[0-9]+.[0-9]+.[0-9]+" + - "leave-dev[0-9]+.[0-9]+.[0-9]+*" + workflow_dispatch: + +env: + REGISTRY: ${{ vars.CONTAINER_REGISTRY }} + REGISTRY_USERNAME: ${{ vars.CONTAINER_REGISTRY_USERNAME }} + REGISTRY_PASSWORD: ${{ secrets.CONTAINER_REGISTRY_PASSWORD }} + CONTAINER_IMAGE_NAME: ${{ vars.CONTAINER_REGISTRY }}/${{ vars.CONTAINER_IMAGE_OWNER }} + IMAGE_VERSION: latest + SERVICE_NAME: hrms-api-leave + DISCORD_WEBHOOK: ${{ vars.DISCORD_WEBHOOK }} + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Tag Version + shell: bash + run: | + if [[ "${{ github.event_name }}" == "push" ]]; then + VERSION=$(echo "${{ github.ref_name }}" | sed 's/leave-dev//g') + echo "IMAGE_VERSION=${VERSION}" >> $GITHUB_ENV + else + echo "IMAGE_VERSION=${{ env.IMAGE_VERSION }}-${{ github.run_number }}" >> $GITHUB_ENV + fi + - name: Login in to registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ env.REGISTRY_USERNAME }} + password: ${{ env.REGISTRY_PASSWORD }} + + - name: Build and push docker image + uses: docker/build-push-action@v5 + with: + platforms: linux/amd64 + context: . + file: ./BMA.EHR.Leave/Dockerfile + tags: ${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}:latest,${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}:${{ env.IMAGE_VERSION }} + push: true + + - name: Remote Deploy + uses: appleboy/ssh-action@v1.2.1 + with: + host: ${{ vars.SSH_DEPLOY_HOST }} + port: ${{ vars.SSH_DEPLOY_PORT }} + username: ${{ secrets.SSH_DEPLOY_USER }} + password: ${{ secrets.SSH_DEPLOY_PASSWORD }} + script: | + cd ~/repo + ./replace-env.sh API_LEAVE "${{ env.IMAGE_VERSION }}" + ./deploy.sh ${{ env.SERVICE_NAME }} + + - name: Discord Notification + if: always() + run: | + STATUS="${{ job.status == 'success' && '✅ Success' || '❌ Failed' }}" + COLOR="${{ job.status == 'success' && '3066993' || '15158332' }}" + TIMESTAMP=$(date -u +%Y-%m-%dT%H:%M:%SZ) + curl -H "Content-Type: application/json" \ + -X POST \ + -d "{ + \"embeds\": [{ + \"title\": \"$STATUS\", + \"description\": \"**Build & Deploy**\\n- Image: \`${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}\`\\n- Version: \`${{ env.IMAGE_VERSION }}\`\\n- By: \`${{ gitea.actor }}\`\", + \"color\": $COLOR, + \"footer\": { + \"text\": \"Release Notification\", + \"icon_url\": \"https://example.com/success-icon.png\" + }, + \"timestamp\": \"$TIMESTAMP\" + }] + }" \ + ${{ env.DISCORD_WEBHOOK }} diff --git a/.forgejo/workflows/build-placement.yml b/.forgejo/workflows/build-placement.yml new file mode 100644 index 00000000..351b1e59 --- /dev/null +++ b/.forgejo/workflows/build-placement.yml @@ -0,0 +1,83 @@ +name: Build & Deploy Placement Service + +on: + push: + tags: + - "placement-dev[0-9]+.[0-9]+.[0-9]+" + - "placement-dev[0-9]+.[0-9]+.[0-9]+*" + workflow_dispatch: + +env: + REGISTRY: ${{ vars.CONTAINER_REGISTRY }} + REGISTRY_USERNAME: ${{ vars.CONTAINER_REGISTRY_USERNAME }} + REGISTRY_PASSWORD: ${{ secrets.CONTAINER_REGISTRY_PASSWORD }} + CONTAINER_IMAGE_NAME: ${{ vars.CONTAINER_REGISTRY }}/${{ vars.CONTAINER_IMAGE_OWNER }} + IMAGE_VERSION: latest + SERVICE_NAME: hrms-api-placement + DISCORD_WEBHOOK: ${{ vars.DISCORD_WEBHOOK }} + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Tag Version + shell: bash + run: | + if [[ "${{ github.event_name }}" == "push" ]]; then + VERSION=$(echo "${{ github.ref_name }}" | sed 's/placement-dev//g') + echo "IMAGE_VERSION=${VERSION}" >> $GITHUB_ENV + else + echo "IMAGE_VERSION=${{ env.IMAGE_VERSION }}-${{ github.run_number }}" >> $GITHUB_ENV + fi + - name: Login in to registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ env.REGISTRY_USERNAME }} + password: ${{ env.REGISTRY_PASSWORD }} + + - name: Build and push docker image + uses: docker/build-push-action@v5 + with: + platforms: linux/amd64 + context: . + file: ./BMA.EHR.Placement.Service/Dockerfile + tags: ${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}:latest,${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}:${{ env.IMAGE_VERSION }} + push: true + + - name: Remote Deploy + uses: appleboy/ssh-action@v1.2.1 + with: + host: ${{ vars.SSH_DEPLOY_HOST }} + port: ${{ vars.SSH_DEPLOY_PORT }} + username: ${{ secrets.SSH_DEPLOY_USER }} + password: ${{ secrets.SSH_DEPLOY_PASSWORD }} + script: | + cd ~/repo + ./replace-env.sh API_PLACEMENT "${{ env.IMAGE_VERSION }}" + ./deploy.sh ${{ env.SERVICE_NAME }} + + - name: Discord Notification + if: always() + run: | + STATUS="${{ job.status == 'success' && '✅ Success' || '❌ Failed' }}" + COLOR="${{ job.status == 'success' && '3066993' || '15158332' }}" + TIMESTAMP=$(date -u +%Y-%m-%dT%H:%M:%SZ) + curl -H "Content-Type: application/json" \ + -X POST \ + -d "{ + \"embeds\": [{ + \"title\": \"$STATUS\", + \"description\": \"**Build & Deploy**\\n- Image: \`${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}\`\\n- Version: \`${{ env.IMAGE_VERSION }}\`\\n- By: \`${{ gitea.actor }}\`\", + \"color\": $COLOR, + \"footer\": { + \"text\": \"Release Notification\", + \"icon_url\": \"https://example.com/success-icon.png\" + }, + \"timestamp\": \"$TIMESTAMP\" + }] + }" \ + ${{ env.DISCORD_WEBHOOK }} diff --git a/.forgejo/workflows/build-report_backup.yml b/.forgejo/workflows/build-report_backup.yml new file mode 100644 index 00000000..664de47b --- /dev/null +++ b/.forgejo/workflows/build-report_backup.yml @@ -0,0 +1,84 @@ +# name: Build + +# on: +# push: +# tags: +# - "report-dev[0-9]+.[0-9]+.[0-9]+" +# - "report-dev[0-9]+.[0-9]+.[0-9]+*" +# workflow_dispatch: + +# env: +# REGISTRY: ${{ vars.CONTAINER_REGISTRY }} +# REGISTRY_USERNAME: ${{ vars.CONTAINER_REGISTRY_USERNAME }} +# REGISTRY_PASSWORD: ${{ secrets.CONTAINER_REGISTRY_PASSWORD }} +# CONTAINER_IMAGE_NAME: ${{ vars.CONTAINER_REGISTRY }}/${{ vars.CONTAINER_IMAGE_OWNER }} +# SERVICE_NAME: hrms-api-report +# IMAGE_VERSION: build +# DISCORD_WEBHOOK: ${{ vars.DISCORD_WEBHOOK }} + +# jobs: +# build: +# runs-on: ubuntu-latest +# steps: +# - name: Checkout repository +# uses: actions/checkout@v4 +# - name: Set up Docker Buildx +# uses: docker/setup-buildx-action@v2 +# with: +# config-inline: | +# [registry."${{ env.REGISTRY }}"] +# ca=["/etc/ssl/certs/ca-certificates.crt"] +# - name: Tag Version +# run: | +# if [[ "${{ github.event_name }}" == "push" ]]; then +# echo "IMAGE_VERSION=${{ github.ref_name }}" | sed 's/report-dev//g' >> $GITHUB_ENV +# else +# echo "IMAGE_VERSION=${{ env.IMAGE_VERSION }}-${{ github.run_number }}" >> $GITHUB_ENV +# fi +# - name: Login in to registry +# uses: docker/login-action@v2 +# with: +# registry: ${{ env.REGISTRY }} +# username: ${{ env.REGISTRY_USERNAME }} +# password: ${{ env.REGISTRY_PASSWORD }} +# - name: Build and push docker image +# uses: docker/build-push-action@v3 +# with: +# platforms: linux/amd64 +# context: . +# file: ./BMA.EHR.Report.Service/Dockerfile +# tags: ${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}:latest,${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}:${{ env.IMAGE_VERSION }} +# push: true +# - name: Remote Deploy +# uses: appleboy/ssh-action@v1.2.1 +# with: +# host: ${{ vars.SSH_DEPLOY_HOST }} +# port: ${{ vars.SSH_DEPLOY_PORT }} +# username: ${{ secrets.SSH_DEPLOY_USER }} +# password: ${{ secrets.SSH_DEPLOY_PASSWORD }} +# script: | +# cd ~/repo +# ./replace-env.sh API_REPORT "${{ env.IMAGE_VERSION }}" +# ./deploy.sh ${{ env.SERVICE_NAME }} + +# - name: Discord Notification +# if: always() +# run: | +# STATUS="${{ job.status == 'success' && '✅ Success' || '❌ Failed' }}" +# COLOR="${{ job.status == 'success' && '3066993' || '15158332' }}" +# TIMESTAMP=$(date -u +%Y-%m-%dT%H:%M:%SZ) +# curl -H "Content-Type: application/json" \ +# -X POST \ +# -d "{ +# \"embeds\": [{ +# \"title\": \"$STATUS\", +# \"description\": \"**Build & Deploy**\\n- Image: \`${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}\`\\n- Version: \`${{ env.IMAGE_VERSION }}\`\\n- By: \`${{ github.actor }}\`\", +# \"color\": $COLOR, +# \"footer\": { +# \"text\": \"Release Notification\", +# \"icon_url\": \"https://example.com/success-icon.png\" +# }, +# \"timestamp\": \"$TIMESTAMP\" +# }] +# }" \ +# ${{ env.DISCORD_WEBHOOK }} diff --git a/.forgejo/workflows/build-retirement.yml b/.forgejo/workflows/build-retirement.yml new file mode 100644 index 00000000..257f68f2 --- /dev/null +++ b/.forgejo/workflows/build-retirement.yml @@ -0,0 +1,83 @@ +name: Build & Deploy Retirement Service + +on: + push: + tags: + - "retirement-dev[0-9]+.[0-9]+.[0-9]+" + - "retirement-dev[0-9]+.[0-9]+.[0-9]+*" + workflow_dispatch: + +env: + REGISTRY: ${{ vars.CONTAINER_REGISTRY }} + REGISTRY_USERNAME: ${{ vars.CONTAINER_REGISTRY_USERNAME }} + REGISTRY_PASSWORD: ${{ secrets.CONTAINER_REGISTRY_PASSWORD }} + CONTAINER_IMAGE_NAME: ${{ vars.CONTAINER_REGISTRY }}/${{ vars.CONTAINER_IMAGE_OWNER }} + IMAGE_VERSION: latest + SERVICE_NAME: hrms-api-retirement + DISCORD_WEBHOOK: ${{ vars.DISCORD_WEBHOOK }} + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Tag Version + shell: bash + run: | + if [[ "${{ github.event_name }}" == "push" ]]; then + VERSION=$(echo "${{ github.ref_name }}" | sed 's/retirement-dev//g') + echo "IMAGE_VERSION=${VERSION}" >> $GITHUB_ENV + else + echo "IMAGE_VERSION=${{ env.IMAGE_VERSION }}-${{ github.run_number }}" >> $GITHUB_ENV + fi + - name: Login in to registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ env.REGISTRY_USERNAME }} + password: ${{ env.REGISTRY_PASSWORD }} + + - name: Build and push docker image + uses: docker/build-push-action@v5 + with: + platforms: linux/amd64 + context: . + file: ./BMA.EHR.Retirement.Service/Dockerfile + tags: ${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}:latest,${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}:${{ env.IMAGE_VERSION }} + push: true + + - name: Remote Deploy + uses: appleboy/ssh-action@v1.2.1 + with: + host: ${{ vars.SSH_DEPLOY_HOST }} + port: ${{ vars.SSH_DEPLOY_PORT }} + username: ${{ secrets.SSH_DEPLOY_USER }} + password: ${{ secrets.SSH_DEPLOY_PASSWORD }} + script: | + cd ~/repo + ./replace-env.sh API_RETIREMENT "${{ env.IMAGE_VERSION }}" + ./deploy.sh ${{ env.SERVICE_NAME }} + + - name: Discord Notification + if: always() + run: | + STATUS="${{ job.status == 'success' && '✅ Success' || '❌ Failed' }}" + COLOR="${{ job.status == 'success' && '3066993' || '15158332' }}" + TIMESTAMP=$(date -u +%Y-%m-%dT%H:%M:%SZ) + curl -H "Content-Type: application/json" \ + -X POST \ + -d "{ + \"embeds\": [{ + \"title\": \"$STATUS\", + \"description\": \"**Build & Deploy**\\n- Image: \`${{ env.CONTAINER_IMAGE_NAME }}/${{ env.SERVICE_NAME }}\`\\n- Version: \`${{ env.IMAGE_VERSION }}\`\\n- By: \`${{ gitea.actor }}\`\", + \"color\": $COLOR, + \"footer\": { + \"text\": \"Release Notification\", + \"icon_url\": \"https://example.com/success-icon.png\" + }, + \"timestamp\": \"$TIMESTAMP\" + }] + }" \ + ${{ env.DISCORD_WEBHOOK }} diff --git a/.forgejo/workflows/build.yml b/.forgejo/workflows/build.yml new file mode 100644 index 00000000..a4f2d2e5 --- /dev/null +++ b/.forgejo/workflows/build.yml @@ -0,0 +1,49 @@ +name: Build + +on: + push: + tags: + - "leave[0-9]+.[0-9]+.[0-9]+" + - "leave[0-9]+.[0-9]+.[0-9]+*" + workflow_dispatch: + +env: + REGISTRY: ${{ vars.CONTAINER_REGISTRY }} + REGISTRY_USERNAME: ${{ vars.CONTAINER_REGISTRY_USERNAME }} + REGISTRY_PASSWORD: ${{ secrets.CONTAINER_REGISTRY_PASSWORD }} + CONTAINER_IMAGE_NAME: ${{ vars.CONTAINER_REGISTRY }}/${{ vars.CONTAINER_IMAGE_OWNER }} + IMAGE_VERSION: build + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + with: + config-inline: | + [registry."${{ env.REGISTRY }}"] + ca=["/etc/ssl/certs/ca-certificates.crt"] + - name: Tag Version + run: | + if [[ "${{ github.event_name }}" == "push" ]]; then + echo "IMAGE_VERSION=${{ github.ref_name }}" | sed 's/leave//g' >> $GITHUB_ENV + else + echo "IMAGE_VERSION=${{ env.IMAGE_VERSION }}-${{ github.run_number }}" >> $GITHUB_ENV + fi + - name: Login in to registry + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ env.REGISTRY_USERNAME }} + password: ${{ env.REGISTRY_PASSWORD }} + - name: Build and push docker image + uses: docker/build-push-action@v3 + with: + platforms: linux/amd64 + context: . + file: ./BMA.EHR.Leave/Dockerfile + tags: ${{ env.CONTAINER_IMAGE_NAME }}/hrms-leave:latest,${{ env.CONTAINER_IMAGE_NAME }}/hrms-leave:${{ env.IMAGE_VERSION }} + push: true diff --git a/.forgejo/workflows/deploy.yml b/.forgejo/workflows/deploy.yml new file mode 100644 index 00000000..7a18d4cc --- /dev/null +++ b/.forgejo/workflows/deploy.yml @@ -0,0 +1,29 @@ +name: Build + +on: + workflow_dispatch: + inputs: + version: + description: "Version to deploy" + type: string + required: false + default: "latest" + +env: + IMAGE_VERSION: build + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Remote Deploy + uses: appleboy/ssh-action@v1.2.1 + with: + host: ${{ vars.SSH_DEPLOY_HOST }} + port: ${{ vars.SSH_DEPLOY_PORT }} + username: ${{ secrets.SSH_DEPLOY_USER }} + password: ${{ secrets.SSH_DEPLOY_PASSWORD }} + script: | + cd ~/repo + ./replace-env.sh API_LEAVE "${{ inputs.version }}" + ./deploy.sh hrms-api-leave diff --git a/.github/workflows/dockerhub-release-checkin.yaml b/.github/workflows/dockerhub-release-checkin.yaml new file mode 100644 index 00000000..9e7c4e23 --- /dev/null +++ b/.github/workflows/dockerhub-release-checkin.yaml @@ -0,0 +1,72 @@ +name: DockerHub Release - CheckIn Consumer +run-name: DockerHub Release - CheckIn Consumer by ${{ github.actor }} +on: + push: + tags: + - "checkin-[0-9]+.[0-9]+.[0-9]+" + workflow_dispatch: + inputs: + IMAGE_VER: + description: "Image version (e.g., latest, v1.0.0)" + required: false + default: "latest" + +env: + DOCKERHUB_REGISTRY: docker.io + IMAGE_NAME: hrms-api-checkin + +jobs: + release-to-dockerhub: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set output tags + id: vars + run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT + + - name: Generate version + id: gen_ver + run: | + if [[ $GITHUB_REF == 'refs/tags/'* ]]; then + IMAGE_VER=${{ steps.vars.outputs.tag }} + else + IMAGE_VER=${{ github.event.inputs.IMAGE_VER }} + fi + if [[ $IMAGE_VER == '' ]]; then + IMAGE_VER='test-vBeta' + fi + echo "image_ver=${IMAGE_VER}" >> $GITHUB_OUTPUT + echo "Generated version: ${IMAGE_VER}" + + - name: Display version + run: | + echo "Git Ref: $GITHUB_REF" + echo "Image Version: ${{ steps.gen_ver.outputs.image_ver }}" + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + registry: ${{env.DOCKERHUB_REGISTRY}} + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: BMA.EHR.CheckInConsumer/Dockerfile + platforms: linux/amd64 + push: true + tags: | + ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ steps.gen_ver.outputs.image_ver }} + ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest + labels: | + org.opencontainers.image.title=BMA EHR CheckIn Consumer + org.opencontainers.image.description=HRMS CheckIn Consumer Service + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/.github/workflows/dockerhub-release-command.yaml b/.github/workflows/dockerhub-release-command.yaml new file mode 100644 index 00000000..33d6b330 --- /dev/null +++ b/.github/workflows/dockerhub-release-command.yaml @@ -0,0 +1,72 @@ +name: DockerHub Release - Command Service +run-name: DockerHub Release - Command Service by ${{ github.actor }} +on: + push: + tags: + - "command-[0-9]+.[0-9]+.[0-9]+" + workflow_dispatch: + inputs: + IMAGE_VER: + description: "Image version (e.g., latest, v1.0.0)" + required: false + default: "latest" + +env: + DOCKERHUB_REGISTRY: docker.io + IMAGE_NAME: hrms-api-command + +jobs: + release-to-dockerhub: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set output tags + id: vars + run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT + + - name: Generate version + id: gen_ver + run: | + if [[ $GITHUB_REF == 'refs/tags/'* ]]; then + IMAGE_VER=${{ steps.vars.outputs.tag }} + else + IMAGE_VER=${{ github.event.inputs.IMAGE_VER }} + fi + if [[ $IMAGE_VER == '' ]]; then + IMAGE_VER='test-vBeta' + fi + echo "image_ver=${IMAGE_VER}" >> $GITHUB_OUTPUT + echo "Generated version: ${IMAGE_VER}" + + - name: Display version + run: | + echo "Git Ref: $GITHUB_REF" + echo "Image Version: ${{ steps.gen_ver.outputs.image_ver }}" + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + registry: ${{env.DOCKERHUB_REGISTRY}} + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: BMA.EHR.Command.Service/Dockerfile + platforms: linux/amd64 + push: true + tags: | + ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ steps.gen_ver.outputs.image_ver }} + ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest + labels: | + org.opencontainers.image.title=BMA EHR Command Service + org.opencontainers.image.description=HRMS Command API Service + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/.github/workflows/dockerhub-release-discipline.yaml b/.github/workflows/dockerhub-release-discipline.yaml new file mode 100644 index 00000000..96096a54 --- /dev/null +++ b/.github/workflows/dockerhub-release-discipline.yaml @@ -0,0 +1,72 @@ +name: DockerHub Release - Discipline Service +run-name: DockerHub Release - Discipline Service by ${{ github.actor }} +on: + push: + tags: + - "discipline-[0-9]+.[0-9]+.[0-9]+" + workflow_dispatch: + inputs: + IMAGE_VER: + description: "Image version (e.g., latest, v1.0.0)" + required: false + default: "latest" + +env: + DOCKERHUB_REGISTRY: docker.io + IMAGE_NAME: hrms-api-discipline + +jobs: + release-to-dockerhub: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set output tags + id: vars + run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT + + - name: Generate version + id: gen_ver + run: | + if [[ $GITHUB_REF == 'refs/tags/'* ]]; then + IMAGE_VER=${{ steps.vars.outputs.tag }} + else + IMAGE_VER=${{ github.event.inputs.IMAGE_VER }} + fi + if [[ $IMAGE_VER == '' ]]; then + IMAGE_VER='test-vBeta' + fi + echo "image_ver=${IMAGE_VER}" >> $GITHUB_OUTPUT + echo "Generated version: ${IMAGE_VER}" + + - name: Display version + run: | + echo "Git Ref: $GITHUB_REF" + echo "Image Version: ${{ steps.gen_ver.outputs.image_ver }}" + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + registry: ${{env.DOCKERHUB_REGISTRY}} + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: BMA.EHR.Discipline.Service/Dockerfile + platforms: linux/amd64 + push: true + tags: | + ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ steps.gen_ver.outputs.image_ver }} + ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest + labels: | + org.opencontainers.image.title=BMA EHR Discipline Service + org.opencontainers.image.description=HRMS Discipline API Service + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/.github/workflows/dockerhub-release-insignia.yaml b/.github/workflows/dockerhub-release-insignia.yaml new file mode 100644 index 00000000..81dae954 --- /dev/null +++ b/.github/workflows/dockerhub-release-insignia.yaml @@ -0,0 +1,72 @@ +name: DockerHub Release - Insignia Service +run-name: DockerHub Release - Insignia Service by ${{ github.actor }} +on: + push: + tags: + - "insignia-[0-9]+.[0-9]+.[0-9]+" + workflow_dispatch: + inputs: + IMAGE_VER: + description: "Image version (e.g., latest, v1.0.0)" + required: false + default: "latest" + +env: + DOCKERHUB_REGISTRY: docker.io + IMAGE_NAME: hrms-api-insignia + +jobs: + release-to-dockerhub: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set output tags + id: vars + run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT + + - name: Generate version + id: gen_ver + run: | + if [[ $GITHUB_REF == 'refs/tags/'* ]]; then + IMAGE_VER=${{ steps.vars.outputs.tag }} + else + IMAGE_VER=${{ github.event.inputs.IMAGE_VER }} + fi + if [[ $IMAGE_VER == '' ]]; then + IMAGE_VER='test-vBeta' + fi + echo "image_ver=${IMAGE_VER}" >> $GITHUB_OUTPUT + echo "Generated version: ${IMAGE_VER}" + + - name: Display version + run: | + echo "Git Ref: $GITHUB_REF" + echo "Image Version: ${{ steps.gen_ver.outputs.image_ver }}" + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + registry: ${{env.DOCKERHUB_REGISTRY}} + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: BMA.EHR.Insignia/Dockerfile + platforms: linux/amd64 + push: true + tags: | + ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ steps.gen_ver.outputs.image_ver }} + ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest + labels: | + org.opencontainers.image.title=BMA EHR Insignia Service + org.opencontainers.image.description=HRMS Insignia API Service + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/.github/workflows/dockerhub-release-leave.yaml b/.github/workflows/dockerhub-release-leave.yaml new file mode 100644 index 00000000..b5a3afe2 --- /dev/null +++ b/.github/workflows/dockerhub-release-leave.yaml @@ -0,0 +1,90 @@ +name: DockerHub Release - Leave Service +run-name: DockerHub Release - Leave Service by ${{ github.actor }} +on: + push: + tags: + - "leave-[0-9]+.[0-9]+.[0-9]+" + # branches: + # - main + # - develop + workflow_dispatch: + inputs: + IMAGE_VER: + description: "Image version (e.g., latest, v1.0.0)" + required: false + default: "latest" + +env: + DOCKERHUB_REGISTRY: docker.io + IMAGE_NAME: hrms-api-leave + +jobs: + release-to-dockerhub: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set output tags + id: vars + run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT + + - name: Generate version + id: gen_ver + run: | + if [[ $GITHUB_REF == 'refs/tags/'* ]]; then + IMAGE_VER=${{ steps.vars.outputs.tag }} + elif [[ $GITHUB_REF == 'refs/heads/'* ]]; then + BRANCH_NAME=${GITHUB_REF#refs/heads/} + IMAGE_VER="${BRANCH_NAME}-latest" + else + IMAGE_VER=${{ github.event.inputs.IMAGE_VER }} + fi + if [[ $IMAGE_VER == '' ]]; then + IMAGE_VER='test-vBeta' + fi + echo "image_ver=${IMAGE_VER}" >> $GITHUB_OUTPUT + echo "Generated version: ${IMAGE_VER}" + + - name: Display version + run: | + echo "Git Ref: $GITHUB_REF" + echo "Image Version: ${{ steps.gen_ver.outputs.image_ver }}" + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + registry: ${{env.DOCKERHUB_REGISTRY}} + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Extract metadata for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=tag + type=ref,event=branch + type=raw,value=${{ steps.gen_ver.outputs.image_ver }} + type=raw,value=latest,enable={{is_default_branch}} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: BMA.EHR.Leave/Dockerfile + platforms: linux/amd64 + push: true + tags: | + ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ steps.gen_ver.outputs.image_ver }} + ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Image digest + run: echo "Image pushed with digest ${{ steps.build.outputs.digest }}" diff --git a/.github/workflows/dockerhub-release-placement.yaml b/.github/workflows/dockerhub-release-placement.yaml new file mode 100644 index 00000000..74fa4471 --- /dev/null +++ b/.github/workflows/dockerhub-release-placement.yaml @@ -0,0 +1,72 @@ +name: DockerHub Release - Placement Service +run-name: DockerHub Release - Placement Service by ${{ github.actor }} +on: + push: + tags: + - "placement-[0-9]+.[0-9]+.[0-9]+" + workflow_dispatch: + inputs: + IMAGE_VER: + description: "Image version (e.g., latest, v1.0.0)" + required: false + default: "latest" + +env: + DOCKERHUB_REGISTRY: docker.io + IMAGE_NAME: hrms-api-placement + +jobs: + release-to-dockerhub: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set output tags + id: vars + run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT + + - name: Generate version + id: gen_ver + run: | + if [[ $GITHUB_REF == 'refs/tags/'* ]]; then + IMAGE_VER=${{ steps.vars.outputs.tag }} + else + IMAGE_VER=${{ github.event.inputs.IMAGE_VER }} + fi + if [[ $IMAGE_VER == '' ]]; then + IMAGE_VER='test-vBeta' + fi + echo "image_ver=${IMAGE_VER}" >> $GITHUB_OUTPUT + echo "Generated version: ${IMAGE_VER}" + + - name: Display version + run: | + echo "Git Ref: $GITHUB_REF" + echo "Image Version: ${{ steps.gen_ver.outputs.image_ver }}" + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + registry: ${{env.DOCKERHUB_REGISTRY}} + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: BMA.EHR.Placement.Service/Dockerfile + platforms: linux/amd64 + push: true + tags: | + ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ steps.gen_ver.outputs.image_ver }} + ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest + labels: | + org.opencontainers.image.title=BMA EHR Placement Service + org.opencontainers.image.description=HRMS Placement API Service + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/.github/workflows/dockerhub-release-report.yaml b/.github/workflows/dockerhub-release-report.yaml new file mode 100644 index 00000000..132b218b --- /dev/null +++ b/.github/workflows/dockerhub-release-report.yaml @@ -0,0 +1,72 @@ +name: DockerHub Release - Report Service +run-name: DockerHub Release - Report Service by ${{ github.actor }} +on: + push: + tags: + - "report-[0-9]+.[0-9]+.[0-9]+" + workflow_dispatch: + inputs: + IMAGE_VER: + description: "Image version (e.g., latest, v1.0.0)" + required: false + default: "latest" + +env: + DOCKERHUB_REGISTRY: docker.io + IMAGE_NAME: hrms-api-report + +jobs: + release-to-dockerhub: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set output tags + id: vars + run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT + + - name: Generate version + id: gen_ver + run: | + if [[ $GITHUB_REF == 'refs/tags/'* ]]; then + IMAGE_VER=${{ steps.vars.outputs.tag }} + else + IMAGE_VER=${{ github.event.inputs.IMAGE_VER }} + fi + if [[ $IMAGE_VER == '' ]]; then + IMAGE_VER='test-vBeta' + fi + echo "image_ver=${IMAGE_VER}" >> $GITHUB_OUTPUT + echo "Generated version: ${IMAGE_VER}" + + - name: Display version + run: | + echo "Git Ref: $GITHUB_REF" + echo "Image Version: ${{ steps.gen_ver.outputs.image_ver }}" + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + registry: ${{env.DOCKERHUB_REGISTRY}} + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: BMA.EHR.Report.Service/Dockerfile + platforms: linux/amd64 + push: true + tags: | + ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ steps.gen_ver.outputs.image_ver }} + ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest + labels: | + org.opencontainers.image.title=BMA EHR Report Service + org.opencontainers.image.description=HRMS Report API Service + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/.github/workflows/dockerhub-release-retirement.yaml b/.github/workflows/dockerhub-release-retirement.yaml new file mode 100644 index 00000000..38e107e6 --- /dev/null +++ b/.github/workflows/dockerhub-release-retirement.yaml @@ -0,0 +1,72 @@ +name: DockerHub Release - Retirement Service +run-name: DockerHub Release - Retirement Service by ${{ github.actor }} +on: + push: + tags: + - "retirement-[0-9]+.[0-9]+.[0-9]+" + workflow_dispatch: + inputs: + IMAGE_VER: + description: "Image version (e.g., latest, v1.0.0)" + required: false + default: "latest" + +env: + DOCKERHUB_REGISTRY: docker.io + IMAGE_NAME: hrms-api-retirement + +jobs: + release-to-dockerhub: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set output tags + id: vars + run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT + + - name: Generate version + id: gen_ver + run: | + if [[ $GITHUB_REF == 'refs/tags/'* ]]; then + IMAGE_VER=${{ steps.vars.outputs.tag }} + else + IMAGE_VER=${{ github.event.inputs.IMAGE_VER }} + fi + if [[ $IMAGE_VER == '' ]]; then + IMAGE_VER='test-vBeta' + fi + echo "image_ver=${IMAGE_VER}" >> $GITHUB_OUTPUT + echo "Generated version: ${IMAGE_VER}" + + - name: Display version + run: | + echo "Git Ref: $GITHUB_REF" + echo "Image Version: ${{ steps.gen_ver.outputs.image_ver }}" + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + registry: ${{env.DOCKERHUB_REGISTRY}} + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: BMA.EHR.Retirement.Service/Dockerfile + platforms: linux/amd64 + push: true + tags: | + ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ steps.gen_ver.outputs.image_ver }} + ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest + labels: | + org.opencontainers.image.title=BMA EHR Retirement Service + org.opencontainers.image.description=HRMS Retirement API Service + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/.github/workflows/release_Retirement.yaml b/.github/workflows/release_Retirement.yaml index 6cdceae0..3fd5bedf 100644 --- a/.github/workflows/release_Retirement.yaml +++ b/.github/workflows/release_Retirement.yaml @@ -1,9 +1,9 @@ name: release-dev run-name: release-dev ${{ github.actor }} on: - push: - tags: - - "retirement-[0-9]+.[0-9]+.[0-9]+" + # push: + # tags: + # - "retirement-[0-9]+.[0-9]+.[0-9]+" workflow_dispatch: env: REGISTRY: docker.frappet.com diff --git a/.github/workflows/release_checkin_consumer.yaml b/.github/workflows/release_checkin_consumer.yaml index 31b015e6..f9081264 100644 --- a/.github/workflows/release_checkin_consumer.yaml +++ b/.github/workflows/release_checkin_consumer.yaml @@ -1,9 +1,9 @@ name: release-dev run-name: release-dev ${{ github.actor }} on: - push: - tags: - - "consumer-[0-9]+.[0-9]+.[0-9]+" + # push: + # tags: + # - "consumer-[0-9]+.[0-9]+.[0-9]+" workflow_dispatch: env: REGISTRY: docker.frappet.com diff --git a/.github/workflows/release_command.yaml b/.github/workflows/release_command.yaml index 462ed688..dba3012e 100644 --- a/.github/workflows/release_command.yaml +++ b/.github/workflows/release_command.yaml @@ -1,9 +1,9 @@ name: release-dev run-name: release-dev ${{ github.actor }} on: - push: - tags: - - "command-[0-9]+.[0-9]+.[0-9]+" + # push: + # tags: + # - "command-[0-9]+.[0-9]+.[0-9]+" workflow_dispatch: env: REGISTRY: docker.frappet.com diff --git a/.github/workflows/release_discipline.yaml b/.github/workflows/release_discipline.yaml index 0e8737f4..f4cb42da 100644 --- a/.github/workflows/release_discipline.yaml +++ b/.github/workflows/release_discipline.yaml @@ -1,9 +1,9 @@ name: release-dev run-name: release-dev ${{ github.actor }} on: - push: - tags: - - "discipline-[0-9]+.[0-9]+.[0-9]+" + # push: + # tags: + # - "discipline-[0-9]+.[0-9]+.[0-9]+" workflow_dispatch: env: REGISTRY: docker.frappet.com diff --git a/.github/workflows/release_insignia.yaml b/.github/workflows/release_insignia.yaml index 124d1e9c..af497b37 100644 --- a/.github/workflows/release_insignia.yaml +++ b/.github/workflows/release_insignia.yaml @@ -1,9 +1,9 @@ name: release-dev run-name: release-dev ${{ github.actor }} on: - push: - tags: - - "insignia-[0-9]+.[0-9]+.[0-9]+" + # push: + # tags: + # - "insignia-[0-9]+.[0-9]+.[0-9]+" workflow_dispatch: env: REGISTRY: docker.frappet.com diff --git a/.github/workflows/release_leave.yaml b/.github/workflows/release_leave.yaml index 4b361f5f..9b5e0014 100644 --- a/.github/workflows/release_leave.yaml +++ b/.github/workflows/release_leave.yaml @@ -1,9 +1,9 @@ name: release-dev run-name: release-dev ${{ github.actor }} on: - push: - tags: - - "leave-[0-9]+.[0-9]+.[0-9]+" + # push: + # tags: + # - "leave-[0-9]+.[0-9]+.[0-9]+" workflow_dispatch: env: REGISTRY: docker.frappet.com diff --git a/.github/workflows/release_placement.yaml b/.github/workflows/release_placement.yaml index d9c2f266..377cbaf4 100644 --- a/.github/workflows/release_placement.yaml +++ b/.github/workflows/release_placement.yaml @@ -1,9 +1,9 @@ name: release-dev run-name: release-dev ${{ github.actor }} on: - push: - tags: - - "placement-[0-9]+.[0-9]+.[0-9]+" + # push: + # tags: + # - "placement-[0-9]+.[0-9]+.[0-9]+" workflow_dispatch: env: REGISTRY: docker.frappet.com diff --git a/.github/workflows/release_report.yaml b/.github/workflows/release_report.yaml index 9ba5a7c4..e529729b 100644 --- a/.github/workflows/release_report.yaml +++ b/.github/workflows/release_report.yaml @@ -1,107 +1,107 @@ name: release-dev run-name: release-dev ${{ github.actor }} on: - push: - tags: - - "reportv2-[0-9]+.[0-9]+.[0-9]+" + # push: + # tags: + # - "reportv2-[0-9]+.[0-9]+.[0-9]+" workflow_dispatch: env: - REGISTRY: docker.frappet.com - IMAGE_NAME: ehr/bma-ehr-report-v2-service - DEPLOY_HOST: frappet.com - DEPLOY_PORT: 10102 - # COMPOSE_PATH: /home/frappet/docker/bma-ehr - COMPOSE_PATH: /home/frappet/docker/bma/bma-ehr-report-v2 - TOKEN_LINE: uxuK5hDzS2DsoC5piJBrWRLiz8GgY7iMZZldOWsDDF0 + REGISTRY: docker.frappet.com + IMAGE_NAME: ehr/bma-ehr-report-v2-service + DEPLOY_HOST: frappet.com + DEPLOY_PORT: 10102 + # COMPOSE_PATH: /home/frappet/docker/bma-ehr + COMPOSE_PATH: /home/frappet/docker/bma/bma-ehr-report-v2 + TOKEN_LINE: uxuK5hDzS2DsoC5piJBrWRLiz8GgY7iMZZldOWsDDF0 jobs: - # act workflow_dispatch -W .github/workflows/release_report.yaml --input IMAGE_VER=latest -s DOCKER_USER=admin -s DOCKER_PASS=FPTadmin2357 -s SSH_PASSWORD=FPTadmin2357 - release-dev: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Set output tags - id: vars - run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT - - name: Gen Version - id: gen_ver - run: | - if [[ $GITHUB_REF == 'refs/tags/'* ]]; then - IMAGE_VER=${{ steps.vars.outputs.tag }} - else - IMAGE_VER=${{ github.event.inputs.IMAGE_VER }} - fi - if [[ $IMAGE_VER == '' ]]; then - IMAGE_VER='test-vBeta' - fi - echo '::set-output name=image_ver::'$IMAGE_VER - - name: Check Version - run: | - echo $GITHUB_REF - echo ${{ steps.gen_ver.outputs.image_ver }} - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - name: Login in to registry - uses: docker/login-action@v2 - with: - registry: ${{env.REGISTRY}} - username: ${{secrets.DOCKER_USER}} - password: ${{secrets.DOCKER_PASS}} - - name: Build and load local docker image - uses: docker/build-push-action@v3 - with: - context: . - platforms: linux/amd64 - file: BMA.EHR.Report.Service/Dockerfile - push: true - tags: ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:${{ steps.gen_ver.outputs.image_ver }},${{env.REGISTRY}}/${{env.IMAGE_NAME}}:latest + # act workflow_dispatch -W .github/workflows/release_report.yaml --input IMAGE_VER=latest -s DOCKER_USER=admin -s DOCKER_PASS=FPTadmin2357 -s SSH_PASSWORD=FPTadmin2357 + release-dev: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set output tags + id: vars + run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT + - name: Gen Version + id: gen_ver + run: | + if [[ $GITHUB_REF == 'refs/tags/'* ]]; then + IMAGE_VER=${{ steps.vars.outputs.tag }} + else + IMAGE_VER=${{ github.event.inputs.IMAGE_VER }} + fi + if [[ $IMAGE_VER == '' ]]; then + IMAGE_VER='test-vBeta' + fi + echo '::set-output name=image_ver::'$IMAGE_VER + - name: Check Version + run: | + echo $GITHUB_REF + echo ${{ steps.gen_ver.outputs.image_ver }} + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Login in to registry + uses: docker/login-action@v2 + with: + registry: ${{env.REGISTRY}} + username: ${{secrets.DOCKER_USER}} + password: ${{secrets.DOCKER_PASS}} + - name: Build and load local docker image + uses: docker/build-push-action@v3 + with: + context: . + platforms: linux/amd64 + file: BMA.EHR.Report.Service/Dockerfile + push: true + tags: ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:${{ steps.gen_ver.outputs.image_ver }},${{env.REGISTRY}}/${{env.IMAGE_NAME}}:latest - - name: Reload docker compose - uses: appleboy/ssh-action@v0.1.8 - with: - host: ${{env.DEPLOY_HOST}} - username: frappet - password: ${{ secrets.SSH_PASSWORD }} - port: ${{env.DEPLOY_PORT}} - script: | - cd "${{env.COMPOSE_PATH}}" - docker compose pull - docker compose up -d - echo "${{ steps.gen_ver.outputs.image_ver }}"> success - - name: Notify Discord Success - if: success() - run: | - curl -H "Content-Type: application/json" \ - -X POST \ - -d '{ - "embeds": [{ - "title": "✅ Deployment Success!", - "description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Deployed by: `${{github.actor}}`", - "color": 3066993, - "footer": { - "text": "Release Notification", - "icon_url": "https://example.com/success-icon.png" - }, - "timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'" - }] - }' \ - ${{ secrets.DISCORD_WEBHOOK }} + - name: Reload docker compose + uses: appleboy/ssh-action@v0.1.8 + with: + host: ${{env.DEPLOY_HOST}} + username: frappet + password: ${{ secrets.SSH_PASSWORD }} + port: ${{env.DEPLOY_PORT}} + script: | + cd "${{env.COMPOSE_PATH}}" + docker compose pull + docker compose up -d + echo "${{ steps.gen_ver.outputs.image_ver }}"> success + - name: Notify Discord Success + if: success() + run: | + curl -H "Content-Type: application/json" \ + -X POST \ + -d '{ + "embeds": [{ + "title": "✅ Deployment Success!", + "description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Deployed by: `${{github.actor}}`", + "color": 3066993, + "footer": { + "text": "Release Notification", + "icon_url": "https://example.com/success-icon.png" + }, + "timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'" + }] + }' \ + ${{ secrets.DISCORD_WEBHOOK }} - - name: Notify Discord Failure - if: failure() - run: | - curl -H "Content-Type: application/json" \ - -X POST \ - -d '{ - "embeds": [{ - "title": "❌ Deployment Failed!", - "description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Attempted by: `${{github.actor}}`", - "color": 15158332, - "footer": { - "text": "Release Notification", - "icon_url": "https://example.com/failure-icon.png" - }, - "timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'" - }] - }' \ - ${{ secrets.DISCORD_WEBHOOK }} + - name: Notify Discord Failure + if: failure() + run: | + curl -H "Content-Type: application/json" \ + -X POST \ + -d '{ + "embeds": [{ + "title": "❌ Deployment Failed!", + "description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Attempted by: `${{github.actor}}`", + "color": 15158332, + "footer": { + "text": "Release Notification", + "icon_url": "https://example.com/failure-icon.png" + }, + "timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'" + }] + }' \ + ${{ secrets.DISCORD_WEBHOOK }} diff --git a/BMA.EHR.Insignia/Services/InsigniaRequestProcessService.cs b/BMA.EHR.Insignia/Services/InsigniaRequestProcessService.cs index e616227c..ecdbabda 100644 --- a/BMA.EHR.Insignia/Services/InsigniaRequestProcessService.cs +++ b/BMA.EHR.Insignia/Services/InsigniaRequestProcessService.cs @@ -35,24 +35,44 @@ public class InsigniaRequestProcessService : BackgroundService #endregion + public override async Task StartAsync(CancellationToken cancellationToken) + { + var client = new SocketIO("wss://hrmsbkk.case-collection.com", + new SocketIOOptions + { + // เพิ่ม token ใน handshake.auth + Auth = new { token = AccessToken ?? "" }, + Path = "/api/v1/org-socket" + }); + + client.OnConnected += async (sender, e) => + { + Console.WriteLine("Connected to Socket.IO server"); + await client.EmitAsync("eventName", "Hello from .NET client"); + }; + + await client.ConnectAsync(); + + await base.StartAsync(cancellationToken); + } //public override async Task StartAsync(CancellationToken cancellationToken) //{ - //var client = new SocketIO("https://bma-ehr.frappet.synology.me/api/v1/org-socket", - // new SocketIOOptions - // { - // // เพิ่ม token ใน handshake.auth - // Auth = new { token = AccessToken ?? "" } - // }); + //var client = new SocketIO("https://bma-ehr.frappet.synology.me/api/v1/org-socket", + // new SocketIOOptions + // { + // // เพิ่ม token ใน handshake.auth + // Auth = new { token = AccessToken ?? "" } + // }); - //client.OnConnected += async (sender, e) => - //{ - // Console.WriteLine("Connected to Socket.IO server"); - // await client.EmitAsync("eventName", "Hello from .NET client"); - //}; + //client.OnConnected += async (sender, e) => + //{ + // Console.WriteLine("Connected to Socket.IO server"); + // await client.EmitAsync("eventName", "Hello from .NET client"); + //}; - //await client.ConnectAsync(); + //await client.ConnectAsync(); - //await base.StartAsync(cancellationToken); + //await base.StartAsync(cancellationToken); //} diff --git a/BMA.EHR.Report.Service/Controllers/RetireReportController.cs b/BMA.EHR.Report.Service/Controllers/RetireReportController.cs index c5c2fa1a..daa4bac6 100644 --- a/BMA.EHR.Report.Service/Controllers/RetireReportController.cs +++ b/BMA.EHR.Report.Service/Controllers/RetireReportController.cs @@ -23,13 +23,17 @@ namespace BMA.EHR.Report.Service.Controllers private readonly IConfiguration _configuration; private readonly PermissionRepository _permission; - public RetireReportController(RetireReportRepository service, IWebHostEnvironment hostingEnvironment, IConfiguration configuration, PermissionRepository permission) + private readonly IHttpContextAccessor _httpContextAccessor; + + public RetireReportController(RetireReportRepository service, IWebHostEnvironment hostingEnvironment, IConfiguration configuration, PermissionRepository permission, IHttpContextAccessor httpContextAccessor) { _service = service; _hostingEnvironment = hostingEnvironment; _configuration = configuration; _permission = permission; + _httpContextAccessor = httpContextAccessor; } + private string? AccessToken => _httpContextAccessor?.HttpContext?.Request.Headers["Authorization"]; #region 31-ประกาศเกษียณข้าราชการ & 32-ประกาศเกษียณลูกจ้างประจำ /// @@ -44,7 +48,7 @@ namespace BMA.EHR.Report.Service.Controllers [HttpGet("{exportType}/{Id}")] public async Task> GetProfileRetirement([FromRoute] Guid Id, string exportType = "pdf") { - var retire = await _service.GetProfileRetirementdAsync(Id,token); + var retire = await _service.GetProfileRetirementdAsync(Id,AccessToken); if (retire != null) { var reportfile = string.Empty;