admin-portal/tech/tabs/01-deploy/05_content.html.php
2025-05-30 12:25:02 +01:00

97 lines
4.8 KiB
PHP

<?php
/*
FILE: 05_content.html.php
Description: the main HTML/PHP content of this tab
*/
?>
<!-- Deploy Tab -->
<div class="tab-pane fade show active" id="deploy">
<!-- Form to pull/merge from public repo -->
<form method="POST" action="?tab=deploy" class="mb-4">
<label class="form-label">Pull an archive ZIP of the entire Codebase from GitHub/GitLab</label>
<p id="github_url_zip"><a href="#" target="_blank"><code>https://github.com/USERNAME/REPO/archive/HASH.zip</code></a></p>
<div class="input-group">
<?php $last = getLastDeployData($repoDir); ?>
<input class="form-control" type="text" name="username" placeholder="USERNAME" value="<?= htmlspecialchars($last['username']) ?>">
<input class="form-control" type="text" name="repo" placeholder="REPO" value="<?= htmlspecialchars($last['repo']) ?>">
<input class="form-control" type="text" name="hash" placeholder="HASH" value="<?= htmlspecialchars($last['hash']) ?>">
<button class="btn btn-primary" type="submit" name="pull_merge_zip">Pull Hash</button>
</div>
</form>
<hr/>
<!-- Direct Upload ZIP Form -->
<form method="POST" action="?tab=deploy" enctype="multipart/form-data" class="mb-4">
<label class="form-label">Directly Upload ZIP</label>
<div class="input-group">
<input class="form-control" type="file" name="upload_zip" accept=".zip" >
<input class="form-control" type="text" name="commit_msg" placeholder="Commit message (optional)">
<button class="btn btn-primary" type="submit" name="upload_zip_btn">Upload & Merge ZIP</button>
</div>
<div class="form-text">The ZIP will be extracted and committed to the repository. Bolt.new /project auto-unwrapped.</div>
</form>
<table class="table table-bordered table-hover mt-4">
<thead>
<tr>
<th>Commit</th>
<th>Date</th>
<th>Description</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php
require_once "02_supportFuncs.php";
foreach (listGitCommits($repoDir) as $commit):
?>
<tr>
<td style="font-family:monospace">
<a href="#"
data-bs-toggle="modal"
data-bs-target="#commitInfoModal"
data-commit-hash="<?= htmlspecialchars($commit['hash']) ?>"
style="text-decoration:underline; cursor:pointer"
title="Show commit details">
<?= htmlspecialchars($commit['hash']) ?>
</a>
</td>
<td><?= htmlspecialchars($commit['date']) ?></td>
<td><?= nl2br(htmlspecialchars($commit['subject'])) ?></td>
<td>
<div class="btn-group">
<button type="button" class="btn btn-success btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
🚀 Deploy
</button>
<ul class="dropdown-menu">
<li>
<form method="POST" action="?tab=deploy" class="d-inline">
<input type="hidden" name="deploy_commit" value="<?= htmlspecialchars($commit['hash']) ?>">
<input type="hidden" name="deploy_target" value="www">
<button type="submit" class="dropdown-item">Deploy to www (production)</button>
</form>
</li>
<li>
<form method="POST" action="?tab=deploy" class="d-inline">
<input type="hidden" name="deploy_commit" value="<?= htmlspecialchars($commit['hash']) ?>">
<input type="hidden" name="deploy_target" value="beta">
<button type="submit" class="dropdown-item">Deploy to beta</button>
</form>
</li>
<li>
<form method="POST" action="?tab=deploy" class="d-inline">
<input type="hidden" name="deploy_commit" value="<?= htmlspecialchars($commit['hash']) ?>">
<input type="hidden" name="deploy_target" value="beta-2">
<button type="submit" class="dropdown-item">Deploy to beta-2</button>
</form>
</li>
</ul>
</div>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>