Add trigger.html
All checks were successful
Greet on Commit / greet (push) Successful in 0s

This commit is contained in:
2025-05-18 12:17:08 +00:00
parent 83da70b9a8
commit fbbc05d994

62
trigger.html Normal file
View File

@@ -0,0 +1,62 @@
<!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>