-
Notifications
You must be signed in to change notification settings - Fork 2
[FEAT] Add cicd for frontend #12
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
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3a3159f
[FEAT] Add cicd for frontend
nadir2609 c7702f2
[FIX] Fix frontend folder name
nadir2609 dc03361
[FIX] Update .github/workflows/frontend-ci-cd.yml
nadir2609 ed01d13
[FIX] Update .github/workflows/frontend-ci-cd.yml
nadir2609 738ad34
[CHORE] Devide CI/CD
nadir2609 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,109 @@ | ||
| name: Frontend - Build & Deploy | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: [ main ] | ||
|
|
||
| jobs: | ||
| frontend-check: | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| VITE_API_URL: ${{ secrets.VITE_API_URL }} | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Use Node.js 24 | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '24.3.0' | ||
| cache: 'npm' | ||
| cache-dependency-path: 'frontend/package-lock.json' | ||
|
|
||
| - name: Install dependencies | ||
| run: npm --prefix frontend ci --legacy-peer-deps | ||
|
|
||
| - name: Build (TS compile + Vite build) | ||
| run: npm --prefix frontend run build | ||
|
|
||
| # Uncomment this if you want linting enabled | ||
| # - name: Lint | ||
| # run: npm --prefix frontend run lint | ||
|
|
||
| - name: Setup Python for upload step | ||
| uses: actions/setup-python@v4 | ||
| with: | ||
| python-version: '3.12.5' | ||
|
|
||
| - name: Install upload dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install requests | ||
|
|
||
| - name: Upload `dist` to hosting service | ||
| env: | ||
| UFAZIEN_HOSTING_BASE_URL: ${{ secrets.UFAZIEN_HOSTING_BASE_URL }} | ||
| UFAZIEN_HOSTING_EMAIL: ${{ secrets.UFAZIEN_HOSTING_EMAIL }} | ||
| UFAZIEN_HOSTING_PASSWORD: ${{ secrets.UFAZIEN_HOSTING_PASSWORD }} | ||
| UFAZIEN_HOSTING_WEBSITE_ID: ${{ secrets.UFAZIEN_HOSTING_WEBSITE_ID }} | ||
|
nadir2609 marked this conversation as resolved.
|
||
| shell: bash | ||
| run: | | ||
| set -euo pipefail | ||
| cd frontend | ||
|
|
||
| if [ ! -d dist ]; then | ||
| echo "❌ dist folder not found - nothing to upload" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "✅ dist folder found, starting upload..." | ||
|
|
||
| python3 <<'PYTHON_SCRIPT' | ||
| import os, requests, glob | ||
|
|
||
| BASE = os.environ.get('UFAZIEN_HOSTING_BASE_URL') | ||
| EMAIL = os.environ.get('UFAZIEN_HOSTING_EMAIL') | ||
| PASSWORD = os.environ.get('UFAZIEN_HOSTING_PASSWORD') | ||
| WEBSITE_ID = os.environ.get('UFAZIEN_HOSTING_WEBSITE_ID') | ||
|
|
||
| if not all([BASE, EMAIL, PASSWORD, WEBSITE_ID]): | ||
| raise SystemExit('Missing one or more required environment variables.') | ||
|
|
||
| login_url = f"{BASE}/auth/login/" | ||
| print('🔐 Logging in to hosting API...') | ||
| resp = requests.post(login_url, json={'email': EMAIL, 'password': PASSWORD}, timeout=30) | ||
| if resp.status_code not in (200, 201): | ||
| print('❌ Login failed:', resp.status_code, resp.text) | ||
| raise SystemExit('Login failed') | ||
|
|
||
| tokens = resp.json() | ||
| access = tokens.get('access') or tokens.get('token') | ||
| if not access: | ||
| print('❌ No access token found in login response:', tokens) | ||
| raise SystemExit('No access token') | ||
|
|
||
| headers = {'Authorization': f'Bearer {access}'} | ||
| dist_root = 'dist' | ||
| files_to_upload = [] | ||
|
|
||
| for path in glob.glob(os.path.join(dist_root, '**'), recursive=True): | ||
| if os.path.isfile(path): | ||
| rel = os.path.relpath(path, dist_root) | ||
| files_to_upload.append(('files', (rel, open(path, 'rb')))) | ||
|
|
||
|
nadir2609 marked this conversation as resolved.
|
||
| if not files_to_upload: | ||
| print('⚠️ No files found in dist to upload.') | ||
| raise SystemExit('No files') | ||
|
|
||
| upload_url = f"{BASE}/hosting/websites/{WEBSITE_ID}/upload_files/" | ||
| print(f'📤 Uploading {len(files_to_upload)} files to {upload_url}...') | ||
|
|
||
| resp = requests.post(upload_url, files=files_to_upload, headers=headers, data={'website_id': WEBSITE_ID}, timeout=120) | ||
| print('🧾 Upload response:', resp.status_code) | ||
| print(resp.text[:1000]) | ||
|
nadir2609 marked this conversation as resolved.
Outdated
|
||
|
|
||
| if resp.status_code not in (200, 201): | ||
| raise SystemExit('❌ Upload failed') | ||
|
|
||
| print('✅ Upload succeeded') | ||
| PYTHON_SCRIPT | ||
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.