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 87d22c5 commit c149cc8
Showing 1 changed file with 51 additions and 37 deletions.
88 changes: 51 additions & 37 deletions _posts/1992-07-12-events.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,57 @@
layout: default
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';
const personalAccessToken = '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';

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

const data = {
ref: ref
// Include inputs here if your workflow requires them
};

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!');
} else {
response.json().then(data => {
alert(`Failed to trigger workflow: ${data.message}`);
});
}
})
.catch(error => {
console.error('Error:', error);
alert('An error occurred while triggering the workflow.');
});
// 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';
// It's highly recommended to handle the token securely on the server side
const personalAccessToken = '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';

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

const data = {
ref: ref
// Include inputs here if your workflow requires them
};

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!');
} else {
response.json().then(data => {
alert(`Failed to trigger workflow: ${data.message}`);
});
}
})
.catch(error => {
console.error('Error:', error);
alert('An error occurred while triggering the workflow.');
});
});
</script>
<script src='/assets/js/vendor/fullcalendar/index.global.min.js'></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 @@ -55,7 +64,12 @@ alert('An error occurred while triggering the workflow.');
events: data
});
calendar.render();
})
.catch(error => {
console.error('Error loading events:', error);
});
});
</script>
{% endraw %}

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

0 comments on commit c149cc8

Please sign in to comment.