63 lines
1.7 KiB
HTML
63 lines
1.7 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<title>Trigger Gitea Workflow</title>
|
|
<style>
|
|
body { font-family: sans-serif; margin: 2rem; }
|
|
input, button { padding: 0.5rem; margin: 0.5rem 0; width: 300px; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h1>Trigger Gitea Workflow</h1>
|
|
|
|
<label for="name">Name:</label><br>
|
|
<input type="text" id="name" value="World"><br>
|
|
|
|
<label for="times">Times:</label><br>
|
|
<input type="number" id="times" value="1" min="1"><br>
|
|
|
|
<label for="token">Token:</label><br>
|
|
<input type="text" id="token" value=""><br>
|
|
|
|
<button onclick="triggerWorkflow()">Run Workflow</button>
|
|
|
|
<p id="status"></p>
|
|
|
|
<script>
|
|
async function triggerWorkflow() {
|
|
const name = document.getElementById('name').value;
|
|
const times = document.getElementById('times').value;
|
|
const token = document.getElementById('token').value;
|
|
|
|
const payload = {
|
|
ref: "main", // or your target branch
|
|
inputs: {
|
|
name: name,
|
|
times: times
|
|
}
|
|
};
|
|
|
|
const response = await fetch("https://gitea.amasson.eu/api/v1/repos/amasson/runner-test/actions/workflows/params-trigger-mac/dispatches", {
|
|
method: "POST",
|
|
headers: {
|
|
"Authorization": `token ${token}`,
|
|
"Content-Type": "application/json"
|
|
},
|
|
body: JSON.stringify(payload)
|
|
});
|
|
|
|
const status = document.getElementById("status");
|
|
if (response.ok) {
|
|
status.textContent = "✅ Workflow triggered successfully.";
|
|
status.style.color = "green";
|
|
} else {
|
|
const error = await response.text();
|
|
status.textContent = `❌ Failed: ${response.status} - ${error}`;
|
|
status.style.color = "red";
|
|
}
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|