API Ecommerce ships a GitHub Actions workflow atDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/JuanSCaicedo/Api-Ecommerce/llms.txt
Use this file to discover all available pages before exploring further.
.github/workflows/main.yml that fully automates deployment to the production server on every push to the main branch. There is a single job — deploy — that opens an SSH connection to the OCI-hosted Ubuntu VPS and executes the deployment script remotely. Cloudflare sits in front of the server as a reverse proxy and CDN, terminating TLS and routing traffic to the application.
Pipeline overview
Trigger: Anygit push to the main branch.
Runner: ubuntu-latest (GitHub-hosted).
Action used: appleboy/ssh-action@v1.0.3 — connects to the server over SSH and runs an inline shell script.
The full deployment workflow:
What the script does
| Step | Description |
|---|---|
set -e | Abort immediately if any command exits with a non-zero status, preventing a partial deploy from leaving the app in a broken state |
ssh-keyscan github.com | Adds GitHub’s host key to known_hosts so the subsequent git pull over SSH does not hang waiting for host confirmation |
git config safe.directory | Required when the repo owner differs from the SSH user — suppresses Git’s “dubious ownership” error |
chown / chmod 775 | Re-establishes correct ownership ($USER:www-data) and group-write permissions across the entire project before touching files |
git remote set-url | Switches the remote to the SSH URL so git pull authenticates via the deploy key rather than HTTPS tokens |
git reset --hard && git pull origin main | Discards any local modifications (e.g. accidental server-side edits) and fast-forwards to the latest commit on main |
composer install --no-dev --optimize-autoloader | Installs only production dependencies and generates an optimised class map |
chmod -R 777 on framework paths | Grants the web server (www-data) write access to the log file and Laravel’s framework cache, view, and session directories |
php artisan optimize:clear | Runs all *:clear sub-commands in one pass, flushing the config, route, view, and event caches |
Deployment target
| Component | Details |
|---|---|
| Host | Oracle Cloud Infrastructure (OCI) — Ubuntu VPS |
| Project root | /home/api-ecommerce.juandevops.com/public_html |
| Web server | Nginx or Apache served from public_html/public/index.php |
| Process user | Deployment SSH user, with www-data as the shared group |
| CDN / Proxy | Cloudflare — handles TLS termination, caching, and DDoS protection in front of the OCI instance |
Required GitHub Secrets
Three secrets must be added to the repository under Settings → Secrets and variables → Actions before the workflow can connect to the server.| Secret | Description |
|---|---|
SERVER_HOST | Public IP address or hostname of the OCI VPS (e.g. 203.0.113.42 or api-ecommerce.juandevops.com) |
SERVER_USERNAME | Linux username that the runner will SSH into (must have sudo access to run chown/chmod commands in the script) |
SSH_PRIVATE_KEY | PEM-encoded private key whose public counterpart is listed in ~/.ssh/authorized_keys on the server |
Manual deployment
If you need to deploy outside of GitHub Actions — for example, after provisioning a new server or rolling back — follow these steps directly on the server.Pull the latest code
SSH into the server and navigate to the project directory, then fetch the latest changes from
main.Install production dependencies
Run Composer without development packages and with classmap optimisation enabled.
Cache configuration and routes
Compile the configuration and route files into their cached equivalents so Laravel does not parse them on every request.
Run database migrations
Apply any pending migrations. The
--force flag is required in non-local environments because Laravel otherwise prompts for confirmation.Health check
Cloudflare proxies the production domain and performs its own availability monitoring. For application-level verification after a deploy:-
HTTP status check — Send a
GETrequest to the API root or a lightweight status endpoint and confirm a200 OKresponse: -
Log review — Inspect the Laravel log for any bootstrap errors immediately after deployment:
-
Cloudflare dashboard — Check the Analytics tab in the Cloudflare dashboard for a spike in
5xxerrors or an unexpected drop in requests, which can indicate a failed deploy.
Because Cloudflare caches static assets and some API responses at the edge, you may need to purge the Cloudflare cache after deploying a change that affects cached routes. Use Cloudflare Dashboard → Caching → Purge Cache, or trigger a purge via the Cloudflare API.