56 lines
3.2 KiB
Markdown
56 lines
3.2 KiB
Markdown
# 01-deploy — Deploy Tab Documentation
|
|
|
|
This tab provides a web interface for source code deployment and management via Git.
|
|
|
|
## Features
|
|
|
|
- **Deploy a specific commit**: Checkout a chosen commit and run build scripts with one click.
|
|
- **Pull and merge ZIP from GitHub/GitLab**: Download a repo archive at a specific commit and merge it into the current working tree.
|
|
- **Direct ZIP upload**: Upload a ZIP file from your computer to merge and commit to the repository.
|
|
- **Browse commit history**: View recent commits, examine their details in a modal, and deploy any commit to a chosen target.
|
|
- **Multiple deploy targets**: Supports easy deployment to `www` (production), `beta`, or `beta-2` via dropdown actions.
|
|
|
|
## File Overview
|
|
|
|
- `01_constants.php` — Defines `$repoDir`, the local path to your code repository. Used everywhere the repo is referenced.
|
|
- `02_supportFuncs.php` — Helper functions for:
|
|
- Running Git commands
|
|
- Listing commits (`listGitCommits()`)
|
|
- Storing and loading last deploy info (`getLastDeployData()`, `setLastDeployData()`)
|
|
- Executing shell command sequences with formatted output (`runShellSteps()`)
|
|
- Sanitizing inputs for hashes/user paths (`sanitizeRepoInput()`)
|
|
- `03_handler.php` — Main backend logic:
|
|
- Handles POST/GET for deploys, ZIP pulls, uploads, and commit info retrieval.
|
|
- Echoes info/error/success blocks for each operation.
|
|
- All sensitive input is sanitized before use in shell commands.
|
|
- `04_nav-item.html.php` — Contains the navigation tab button HTML for activating the Deploy tab.
|
|
- `05_content.html.php` — Main UI HTML:
|
|
- Forms for ZIP pull/upload.
|
|
- Table of recent commits, each with deploy dropdown for all targets.
|
|
- Commit history linked to the modal for details.
|
|
- `06_modals.html.php` — Bootstrap modal for commit details, loaded on demand by JavaScript.
|
|
- `07_javascript.js` —
|
|
- Handles dynamic loading of commit info into the modal via AJAX/fetch.
|
|
- Live URL preview while typing GitHub repo/hash for ZIP pulls.
|
|
|
|
## Usage
|
|
|
|
1. **Deploy a commit**: Click the dropdown next to a commit, select your target, and the backend will checkout, install, build, and deploy that revision.
|
|
2. **Merge from GitHub**: Fill in username/repo/hash and click to pull & merge that remote ZIP into your codebase.
|
|
3. **Upload ZIP**: Upload a ZIP file (from external export or other CI pipeline) and have its content merged and committed to the repo.
|
|
4. **View commit details**: Click any commit in the table to view the full diff, author, date, and message in a modal.
|
|
|
|
## Security & Safety
|
|
|
|
- Inputs are sanitized before being passed to shell or git commands.
|
|
- Only users with web access to the admin panel can trigger deploy steps.
|
|
- All output from shell commands is displayed to the user for transparency.
|
|
|
|
## Customization
|
|
|
|
- To update what happens on deployment, edit the `$steps` arrays in `03_handler.php`.
|
|
- For new deploy targets, adjust forms and handler logic as needed.
|
|
- The build sequence (npm, asto, rsync, etc.) can be tailored for your tech stack.
|
|
|
|
---
|
|
This tab is a minimal self-service deployment panel fitting teams who need to pull, merge, and deploy new code quickly, review git history, and provide a safe admin pathway for ops and releases. |