diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a80e6de..55a6038 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,6 +10,8 @@ env: IMAGE_NAME: ehr/bma-ehr-log-backup DEPLOY_HOST: 49.0.91.80 COMPOSE_PATH: /home/frappet/docker/bma/bma-ehr-log-backup + DISCORD_WEBHOOK: https://discord.com/api/webhooks/1313895135121248377/ph4LEfzvrNKyPKouCfHkKx73E323sAc--f3aIM2N0pvS-lQaGdBOg-yHxSNNFxfvjob7 + jobs: release: runs-on: ubuntu-latest @@ -64,21 +66,40 @@ jobs: docker compose pull docker compose up -d echo "${{ steps.gen_ver.outputs.image_ver }}"> success - - uses: snow-actions/line-notify@v1.1.0 + - name: Notify Discord Success if: success() - with: - access_token: ${{ secrets.TOKEN_LINE }} - message: | - ✅ - Image: ${{ env.IMAGE_NAME }} - Version: ${{ steps.gen_ver.outputs.IMAGE_VER }} - By: ${{github.actor}} - - uses: snow-actions/line-notify@v1.1.0 + 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)'" + }] + }' \ + ${{ env.DISCORD_WEBHOOK }} + + - name: Notify Discord Failure if: failure() - with: - access_token: ${{ secrets.TOKEN_LINE }} - message: | - ❌ - Image: ${{ env.IMAGE_NAME }} - Version: ${{ steps.gen_ver.outputs.IMAGE_VER }} - By: ${{github.actor}} + 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)'" + }] + }' \ + ${{ env.DISCORD_WEBHOOK }} diff --git a/docker/Dockerfile b/docker/Dockerfile index 6faa727..6767e59 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,30 +1,25 @@ -# Base stage -FROM node:lts-alpine AS base +FROM node:20-slim AS base + ENV PNPM_HOME="/pnpm" ENV PATH="$PNPM_HOME:$PATH" RUN corepack enable + WORKDIR /app + COPY . . -# Dependencies stage FROM base AS deps RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile -# Build stage FROM base AS build RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile RUN pnpm run build -# Production stage -FROM node:lts-alpine AS prod +FROM base as prod ENV NODE_ENV="production" -WORKDIR /app - -# Copy necessary files from previous stages COPY --from=deps /app/node_modules /app/node_modules COPY --from=build /app/dist /app/dist COPY --from=base /app/static /app/static -# Start the application CMD ["pnpm", "run", "start"]