-
Notifications
You must be signed in to change notification settings - Fork 0
feat: migrate to pnpm, enhance Docker and deployment workflows, and improve clipboard OTP UX #362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
38465f3
chore: migrate project to pnpm and update dependencies
mrbadri f66038d
refactor: update docker-compose configuration for core-client service
mrbadri a5502ca
feat: add docker-compose configuration for core-client service
mrbadri a56d9a0
feat: add environment variables to Dockerfile for base URL configurat…
mrbadri 18fba39
fix: update base URL in coreApi and guestApi to a hardcoded value
mrbadri 42fb53a
feat: enhance authentication components with clipboard OTP functionality
mrbadri 4f355a4
feat: add clipboard permission request functionality to useClipboardO…
mrbadri 724450c
feat: implement clipboard permission listener in useClipboardOtp hook
mrbadri 33292f7
feat: add deploy action
mrbadri dbde556
feat: add production docker-compose configuration for core-client ser…
mrbadri 75388c3
refactor: update docker-compose configuration for client service
mrbadri c44ef34
chore: enhance Docker Hub deployment process in workflow
mrbadri 84d2f80
chore: clean up Docker deployment workflow
mrbadri ce1f8b6
fix: update Docker deployment workflow to pull client service
mrbadri 8253870
chore: remove commented-out Docker build and push steps from deployme…
mrbadri 40fa684
chore: add concurrency configuration to deployment workflow
mrbadri 6e06020
chore: update deployment workflow to use self-hosted runners
mrbadri e38ce6f
chore: expose port for core service in production Docker Compose
mrbadri 10046db
fix: update API base URLs from HTTPS to HTTP
mrbadri 1a21f6c
refactor: simplify post-login schema transformation and update docker…
mrbadri 1ecb3c2
feat: add development and preview Docker Compose configurations
mrbadri 47b4846
refactor: update PR comment actions in deployment workflow
mrbadri 4ee4a08
chore: update permissions in deployment workflow
mrbadri File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,201 @@ | ||
| name: CI/CD Pipeline | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| - dev | ||
| pull_request: | ||
| types: [opened, synchronize, reopened, closed] | ||
|
|
||
| concurrency: | ||
| group: "CI-${{ github.ref_name }}-${{ github.event.number || github.sha }}" | ||
| cancel-in-progress: true | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
| issues: write | ||
|
|
||
| jobs: | ||
| # Build job for all scenarios | ||
| build: | ||
| runs-on: [self-hosted, core] | ||
| if: github.event.action != 'closed' | ||
| outputs: | ||
| image-tag: ${{ steps.image-tag.outputs.tag }} | ||
| port: ${{ steps.port.outputs.port }} | ||
| steps: | ||
| - name: Checkout Repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Determine image tag and port | ||
| id: image-tag | ||
| run: | | ||
| if [ "${{ github.ref_name }}" = "main" ]; then | ||
| echo "tag=latest" >> $GITHUB_OUTPUT | ||
| elif [ "${{ github.ref_name }}" = "dev" ]; then | ||
| echo "tag=dev" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "tag=pr-${{ github.event.number }}" >> $GITHUB_OUTPUT | ||
| fi | ||
| - name: Determine port for PR | ||
| id: port | ||
| run: | | ||
| if [ "${{ github.event_name }}" = "pull_request" ]; then | ||
| # Calculate port: 3100 + PR number (ensures unique ports) | ||
| PORT=$((3100 + ${{ github.event.number }})) | ||
| echo "port=$PORT" >> $GITHUB_OUTPUT | ||
| fi | ||
mrbadri marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - name: Create .env file | ||
| run: | | ||
| echo "NEXT_PUBLIC_BASE_URL=${{ secrets.NEXT_PUBLIC_BASE_URL }}" >> .env | ||
| echo "NEXT_PUBLIC_BASE_URL_ATTACHMENT=${{ secrets.NEXT_PUBLIC_BASE_URL_ATTACHMENT }}" >> .env | ||
| - name: Login to Docker Hub | ||
| run: docker login -u mrbadri -p ${{ secrets.DOCKER_TOKEN }} | ||
|
|
||
| - name: Build Docker Image | ||
| run: | | ||
| TAG=${{ steps.image-tag.outputs.tag }} | ||
| if [ "${{ github.ref_name }}" = "main" ]; then | ||
| docker compose -f docker-compose.prod.yml build | ||
| elif [ "${{ github.ref_name }}" = "dev" ]; then | ||
| docker compose -f docker-compose.dev.yml build | ||
| docker tag mrbadri/pixel-client:dev mrbadri/pixel-client:$TAG | ||
| else | ||
| # For PR - build and tag | ||
| docker build -t mrbadri/pixel-client:$TAG -f ./apps/core/Dockerfile . | ||
| fi | ||
mrbadri marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - name: Push Docker Image to Docker Hub | ||
| run: | | ||
| TAG=${{ steps.image-tag.outputs.tag }} | ||
| docker push mrbadri/pixel-client:$TAG | ||
| # Deploy to production (main branch) | ||
| deploy-production: | ||
| runs-on: [self-hosted, core] | ||
| needs: build | ||
| if: github.ref_name == 'main' && github.event_name == 'push' | ||
| steps: | ||
| - name: Checkout Repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Create .env file | ||
| run: | | ||
| echo "NEXT_PUBLIC_BASE_URL=${{ secrets.NEXT_PUBLIC_BASE_URL }}" >> .env | ||
| echo "NEXT_PUBLIC_BASE_URL_ATTACHMENT=${{ secrets.NEXT_PUBLIC_BASE_URL_ATTACHMENT }}" >> .env | ||
| - name: Deploy Production | ||
| run: | | ||
| docker compose -f docker-compose.prod.yml pull client | ||
| docker compose -f docker-compose.prod.yml down || true | ||
| docker compose -f docker-compose.prod.yml up -d | ||
| # Deploy to development (dev branch) | ||
| deploy-development: | ||
| runs-on: [self-hosted, core] | ||
| needs: build | ||
| if: github.ref_name == 'dev' && github.event_name == 'push' | ||
| steps: | ||
| - name: Checkout Repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Create .env file | ||
| run: | | ||
| echo "NEXT_PUBLIC_BASE_URL=${{ secrets.NEXT_PUBLIC_BASE_URL }}" >> .env | ||
| echo "NEXT_PUBLIC_BASE_URL_ATTACHMENT=${{ secrets.NEXT_PUBLIC_BASE_URL_ATTACHMENT }}" >> .env | ||
| - name: Deploy Development | ||
| run: | | ||
| docker compose -f docker-compose.dev.yml pull client-dev | ||
| docker compose -f docker-compose.dev.yml down || true | ||
| docker compose -f docker-compose.dev.yml up -d | ||
| # Deploy PR preview | ||
| deploy-preview: | ||
| runs-on: [self-hosted, core] | ||
| needs: build | ||
| if: github.event_name == 'pull_request' && github.event.action != 'closed' | ||
| steps: | ||
| - name: Checkout Repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Create .env file | ||
| run: | | ||
| echo "NEXT_PUBLIC_BASE_URL=${{ secrets.NEXT_PUBLIC_BASE_URL }}" >> .env | ||
| echo "NEXT_PUBLIC_BASE_URL_ATTACHMENT=${{ secrets.NEXT_PUBLIC_BASE_URL_ATTACHMENT }}" >> .env | ||
| - name: Create PR-specific compose file | ||
| run: | | ||
| PR_NUMBER=${{ github.event.number }} | ||
| PORT=${{ needs.build.outputs.port }} | ||
| # Create PR-specific docker-compose file | ||
| sed "s/PR_NUMBER/$PR_NUMBER/g; s/PORT_NUMBER/$PORT/g" docker-compose.preview.yml > docker-compose.pr-$PR_NUMBER.yml | ||
| - name: Deploy Preview | ||
| run: | | ||
| PR_NUMBER=${{ github.event.number }} | ||
| # Pull the image | ||
| docker pull mrbadri/pixel-client:pr-$PR_NUMBER | ||
| # Stop and remove existing preview if exists | ||
| docker compose -f docker-compose.pr-$PR_NUMBER.yml down || true | ||
| # Start the preview | ||
| docker compose -f docker-compose.pr-$PR_NUMBER.yml up -d | ||
| - name: Comment PR with preview link | ||
| uses: marocchino/sticky-pull-request-comment@v2 | ||
| with: | ||
| header: preview-deployment | ||
| message: | | ||
| ### 🚀 Preview Deployed Successfully! | ||
| Your pull request preview is now available: | ||
| - 📍 **Preview URL**: http://82.115.24.87:${{ needs.build.outputs.port }} | ||
| - 🔗 **Container**: `client-preview-${{ github.event.number }}` | ||
| - 🐳 **Image**: `mrbadri/pixel-client:pr-${{ github.event.number }}` | ||
| This preview will be automatically cleaned up when the PR is closed. | ||
| # Cleanup PR preview when closed | ||
| cleanup-preview: | ||
| runs-on: [self-hosted, core] | ||
| if: github.event_name == 'pull_request' && github.event.action == 'closed' | ||
| steps: | ||
| - name: Checkout Repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Cleanup PR preview | ||
| run: | | ||
| PR_NUMBER=${{ github.event.number }} | ||
| # Stop and remove preview containers | ||
| docker compose -f docker-compose.pr-$PR_NUMBER.yml down || true | ||
| # Remove the compose file | ||
| rm -f docker-compose.pr-$PR_NUMBER.yml || true | ||
| # Remove the Docker image | ||
| docker rmi mrbadri/pixel-client:pr-$PR_NUMBER || true | ||
| - name: Post Cleanup Confirmation Comment | ||
| if: always() | ||
| uses: marocchino/sticky-pull-request-comment@v2 | ||
| with: | ||
| header: preview-cleanup | ||
| message: | | ||
| ### 🧹 Preview Cleanup Complete | ||
| All preview deployment resources for this pull request have been successfully removed: | ||
| - 🐳 Docker container `client-preview-${{ github.event.number }}` stopped and removed | ||
| - 📦 Docker image `mrbadri/pixel-client:pr-${{ github.event.number }}` cleaned up | ||
| - 📁 Docker compose file removed | ||
| The cleanup process has finished for PR #${{ github.event.number }}. | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -8,37 +8,46 @@ import { Button, Input } from "@repo/ui/components"; | |
| import { postForgetPasswordSchema } from "@repo/apis/core/accounts/users/forgot-password/post/post-forget-password.schema"; | ||
| import type { PostForgetPasswordRequest } from "@repo/apis/core/accounts/users/forgot-password/post/post-forget-password.types"; | ||
| import { UsePostForgetPassword } from "@repo/apis/core/accounts/users/forgot-password/post/use-post-forget-password"; | ||
| import { useEffect } from "react"; | ||
|
|
||
| const ForgetPasswordForm = () => { | ||
| const router = useRouter(); | ||
|
|
||
| const form = useForm<PostForgetPasswordRequest>({ | ||
| resolver: zodResolver(postForgetPasswordSchema.request), | ||
| }); | ||
|
|
||
| const { | ||
| register, | ||
| formState: { errors }, | ||
| handleSubmit, | ||
| } = form; | ||
|
|
||
| const mutation = UsePostForgetPassword({ | ||
| onSuccess: (res, context) => { | ||
| toast.info(res.data.message); | ||
| router.replace(`/auth/set-password?username=${context.username}`); | ||
| }, | ||
| onError: (err) => { | ||
| toast.error(err.response?.data.message ?? "Something went wrong"); | ||
| }, | ||
| }); | ||
|
|
||
| const onSubmit = (data: PostForgetPasswordRequest) => { | ||
| mutation.mutate(data); | ||
| }; | ||
|
|
||
| useEffect(() => { | ||
| router.prefetch("/auth/set-password"); | ||
| }, [router]); | ||
|
|
||
| return ( | ||
| <form onSubmit={handleSubmit(onSubmit)} className="w-full pb-7"> | ||
| <Input | ||
| label="Username" | ||
| className="font-normal text-xs" | ||
| placeholder="[email protected]" | ||
| placeholder="Enter your username" | ||
| autoFocus | ||
| {...register("username")} | ||
| error={errors.username?.message} | ||
| /> | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.