Skip to content

Commit

Permalink
Update 1992-07-12-events.md
Browse files Browse the repository at this point in the history
  • Loading branch information
ibbsbbr authored Sep 19, 2024
1 parent 7e2a470 commit 63b5460
Showing 1 changed file with 10 additions and 24 deletions.
34 changes: 10 additions & 24 deletions _posts/1992-07-12-events.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,29 @@ slug: events

<button id="triggerWorkflow">Events</button>

{% raw %}
<script>
document.getElementById('triggerWorkflow').addEventListener('click', () => {
// Configuration Variables
const owner = 'marioseixas';
const repo = 'marioseixas.github.io';
const workflow_id = 'jekyll.yml'; // Can also be the workflow ID number
const ref = 'main';

// Base64-encoded Personal Access Token
const encodedPAT = 'Z2hwX0JzaXBQY1B6OGx2SlMwc0toTmlGeTlvZmZEczVvNTJPN1NsQQ=='; // Example Base64 string

// Decode the Base64-encoded PAT
const personalAccessToken = atob(encodedPAT);

const url = `https://api.github.com/repos/${owner}/${repo}/actions/workflows/${workflow_id}/dispatches`;

const url = `https://api.github.com/repos/marioseixas/marioseixas.github.io/actions/workflows/trigger-workflow.yml/dispatches`;

const data = {
ref: ref
// Include inputs here if your workflow requires them
ref: 'main',
inputs: {
run_workflow: 'yes'
}
};


// Initiate the workflow dispatch without exposing the PAT
fetch(url, {
method: 'POST',
headers: {
'Authorization': `token ${personalAccessToken}`,
'Accept': 'application/vnd.github.v3+json',
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
})
.then(response => {
if (response.status === 204) {
alert('Workflow triggered successfully!');
if (response.status === 201) {
alert('Workflow trigger initiated successfully!');
} else {
response.json().then(data => {
alert(`Failed to trigger workflow: ${data.message}`);
Expand All @@ -51,12 +40,10 @@ document.getElementById('triggerWorkflow').addEventListener('click', () => {
});
});
</script>
{% endraw %}

<!-- Load FullCalendar Library -->
<script src="/assets/js/vendor/fullcalendar/index.global.min.js"></script>

{% raw %}
<script>
document.addEventListener('DOMContentLoaded', function() {
var calendarEl = document.getElementById('calendar');
Expand All @@ -74,6 +61,5 @@ document.getElementById('triggerWorkflow').addEventListener('click', () => {
});
});
</script>
{% endraw %}

<div id="calendar"></div>

0 comments on commit 63b5460

Please sign in to comment.