From 74dd91ef9a884d878ffbc835302feff3dd6de42c Mon Sep 17 00:00:00 2001 From: Suchin Sapphasitthatha Date: Fri, 20 Dec 2024 09:42:59 +0000 Subject: [PATCH 1/7] add CI --- .onedev-buildspec.yml | 103 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 .onedev-buildspec.yml diff --git a/.onedev-buildspec.yml b/.onedev-buildspec.yml new file mode 100644 index 0000000..9a877df --- /dev/null +++ b/.onedev-buildspec.yml @@ -0,0 +1,103 @@ +version: 37 +jobs: +- name: CI for UAT + steps: + - !CheckoutStep + name: checkout code + cloneCredential: !DefaultCredential {} + withLfs: false + withSubmodules: false + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + - !GenerateChecksumStep + name: generate package checksum + files: package-lock.json yarn.lock + targetFile: checksum + condition: NEVER + - !SetupCacheStep + name: set up npm cache + key: node_modules_@file:checksum@ + loadKeys: + - node_modules + paths: + - node_modules + uploadStrategy: UPLOAD_IF_NOT_HIT + condition: NEVER + - !SetBuildVersionStep + name: set build version + buildVersion: '@tag@' + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + - !CommandStep + name: build & test + runInContainer: true + image: node + interpreter: !DefaultInterpreter + commands: | + npm install + npm run build + useTTY: true + condition: NEVER + - !BuildImageStep + name: build docker image + dockerfile: ./docker/Dockerfile + output: !RegistryOutput + tags: hrms-git.chin.in.th/bma-hrms/hrms-edm:@build_version@ hrms-git.chin.in.th/bma-hrms/hrms-edm:latest + platforms: linux/amd64 + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + triggers: + - !TagCreateTrigger + tags: uat-* + branches: main + retryCondition: never + maxRetries: 3 + retryDelay: 30 + timeout: 14400 +- name: CI for PROD + steps: + - !CheckoutStep + name: checkout code + cloneCredential: !DefaultCredential {} + withLfs: false + withSubmodules: false + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + - !GenerateChecksumStep + name: generate package checksum + files: package-lock.json yarn.lock + targetFile: checksum + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + - !SetupCacheStep + name: set up npm cache + key: node_modules_@file:checksum@ + loadKeys: + - node_modules + paths: + - node_modules + uploadStrategy: UPLOAD_IF_NOT_HIT + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + - !SetBuildVersionStep + name: set build version + buildVersion: '@tag@' + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + - !CommandStep + name: build & test + runInContainer: true + image: node + interpreter: !DefaultInterpreter + commands: | + npm install + npm run build + useTTY: true + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + - !BuildImageStep + name: build docker image + dockerfile: ./docker/Dockerfile + output: !RegistryOutput + tags: hrms-git.bangkok.go.th/bma-hrms/hrms-edm:@build_version@ hrms-git.bangkok.go.th/bma-hrms/hrms-edm:latest + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + triggers: + - !TagCreateTrigger + tags: prod-* + branches: main + retryCondition: never + maxRetries: 3 + retryDelay: 30 + timeout: 14400 From c211c75f83f42c072e07c75ba8d69a9932f7aa94 Mon Sep 17 00:00:00 2001 From: Suchin Sapphasitthatha Date: Fri, 20 Dec 2024 09:44:09 +0000 Subject: [PATCH 2/7] modify CI --- .onedev-buildspec.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.onedev-buildspec.yml b/.onedev-buildspec.yml index 9a877df..012135c 100644 --- a/.onedev-buildspec.yml +++ b/.onedev-buildspec.yml @@ -38,7 +38,7 @@ jobs: condition: NEVER - !BuildImageStep name: build docker image - dockerfile: ./docker/Dockerfile + dockerfile: ./Services/Dockerfile output: !RegistryOutput tags: hrms-git.chin.in.th/bma-hrms/hrms-edm:@build_version@ hrms-git.chin.in.th/bma-hrms/hrms-edm:latest platforms: linux/amd64 From ac1d85f6724d4d1f0f854df8bfa22104ad103f8f Mon Sep 17 00:00:00 2001 From: waruneeauy Date: Wed, 7 Jan 2026 20:28:21 +0700 Subject: [PATCH 3/7] build docker hub --- .github/workflows/build.yaml | 91 ++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 .github/workflows/build.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..450a2ed --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,91 @@ +name: build to DockerHub +run-name: build ${{ github.actor }} +on: + push: + tags: + - "checkin-[0-9]+.[0-9]+.[0-9]+" + workflow_dispatch: + +env: + DOCKERHUB_REGISTRY: docker.io + IMAGE_NAME: hrms-edm + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v3 + + - name: Generate Version + id: gen_ver + run: | + if [[ $GITHUB_REF == 'refs/heads/'* ]]; then + BRANCH_NAME="${GITHUB_REF##*/}" + IMAGE_VER="$BRANCH_NAME-$(date +%Y%m%d)-${GITHUB_SHA::7}" + else + IMAGE_VER="pr-${GITHUB_SHA::7}" + fi + echo "{\"version\":\"$IMAGE_VER\", \"date\":\"$(date +"%Y-%m-%d_%T")\",\"ref\":\"$GITHUB_REF\", \"sha\":\"$GITHUB_SHA\" }" > ./Services/server/src/version.json + echo "image_ver=$IMAGE_VER" >> $GITHUB_OUTPUT + echo "Build version: $IMAGE_VER" + cat ./Services/server/src/version.json + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push to DockerHub + uses: docker/build-push-action@v3 + with: + context: ./Services + platforms: linux/amd64,linux/arm64 + push: true + tags: | + ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ steps.gen_ver.outputs.image_ver }} + ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest + cache-from: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:buildcache + cache-to: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:buildcache,mode=max + + - name: Notify Discord Success + if: success() + run: | + curl -H "Content-Type: application/json" \ + -X POST \ + -d '{ + "embeds": [{ + "title": "✅ Build Success!", + "description": "**Details:**\n- Image: `${{ secrets.DOCKERHUB_USERNAME }}/${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Branch: `${{ github.ref_name }}`\n- Built by: `${{github.actor}}`", + "color": 3066993, + "footer": { + "text": "Build 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": "❌ Build Failed!", + "description": "**Details:**\n- Image: `${{ secrets.DOCKERHUB_USERNAME }}/${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Branch: `${{ github.ref_name }}`\n- Attempted by: `${{github.actor}}`", + "color": 15158332, + "footer": { + "text": "Build Notification", + "icon_url": "https://example.com/failure-icon.png" + }, + "timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'" + }] + }' \ + ${{ secrets.DISCORD_WEBHOOK }} From f47fb9618117cecff49df823d6d1e54eebd99768 Mon Sep 17 00:00:00 2001 From: waruneeauy Date: Wed, 7 Jan 2026 20:31:05 +0700 Subject: [PATCH 4/7] fix tag --- .github/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 450a2ed..5526a8d 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -3,7 +3,7 @@ run-name: build ${{ github.actor }} on: push: tags: - - "checkin-[0-9]+.[0-9]+.[0-9]+" + - "edm-[0-9]+.[0-9]+.[0-9]+" workflow_dispatch: env: From b2d93034dcb499ebde522e279b96be3348c467d7 Mon Sep 17 00:00:00 2001 From: kittapath <> Date: Tue, 27 Jan 2026 01:30:46 +0700 Subject: [PATCH 5/7] console role --- Services/client/src/router/index.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Services/client/src/router/index.ts b/Services/client/src/router/index.ts index 32534ef..446941f 100644 --- a/Services/client/src/router/index.ts +++ b/Services/client/src/router/index.ts @@ -29,10 +29,14 @@ const router = createRouter({ name: 'AdminModule', component: () => import('@/views/MainLayout.vue'), beforeEnter: async (_to, _from, next) => { + console.log('AdminModule - beforeEnter') const token = await getToken() + console.log(token) if (token) { + console.log('11111') const roles = getRole() + console.log(roles) if ( token && From e809dfde4a77a5afda3293ca3d6521a3f956928f Mon Sep 17 00:00:00 2001 From: kittapath <> Date: Tue, 27 Jan 2026 01:34:26 +0700 Subject: [PATCH 6/7] add remote deploy --- .forgejo/workflows/build.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.forgejo/workflows/build.yml b/.forgejo/workflows/build.yml index 285a66a..eaf2d93 100644 --- a/.forgejo/workflows/build.yml +++ b/.forgejo/workflows/build.yml @@ -47,3 +47,14 @@ jobs: file: ./Services/Dockerfile tags: ${{ env.CONTAINER_IMAGE_NAME }}:latest,${{ env.CONTAINER_IMAGE_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_ORG "${{ env.IMAGE_VERSION }}" + ./deploy.sh hrms-api-org From e632125ef4e478ca949b7cd9be65944e371bd21b Mon Sep 17 00:00:00 2001 From: kittapath <> Date: Tue, 27 Jan 2026 11:04:14 +0700 Subject: [PATCH 7/7] remove deploy tag --- .forgejo/workflows/build.yml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/.forgejo/workflows/build.yml b/.forgejo/workflows/build.yml index eaf2d93..285a66a 100644 --- a/.forgejo/workflows/build.yml +++ b/.forgejo/workflows/build.yml @@ -47,14 +47,3 @@ jobs: file: ./Services/Dockerfile tags: ${{ env.CONTAINER_IMAGE_NAME }}:latest,${{ env.CONTAINER_IMAGE_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_ORG "${{ env.IMAGE_VERSION }}" - ./deploy.sh hrms-api-org