Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: CI

on:
push:
branches: [ main ]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: Publish to PyPI

on:
push:
tags:
Expand Down
44 changes: 44 additions & 0 deletions .github/workflows/trivia.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
name: Trivia on a pull request
on:
pull_request:
types: [opened]

jobs:
trivia:
runs-on: ubuntu-latest

steps:
- name: Post Trivia Questions
uses: actions/github-script@v7
with:
script: |
const res = await fetch("https://opentdb.com/api.php?amount=3&difficulty=medium&type=multiple");
const data = await res.json();

function decodeHtml(html) {
return html
.replace(/"/g, '"')
.replace(/'/g, "'")
.replace(/&/g, "&")
.replace(/&lt;/g, "<")
.replace(/&gt;/g, ">");
}

const questions = data.results.map((q, i) => {
const choices = [...q.incorrect_answers, q.correct_answer]
.sort(() => Math.random() - 0.5)
.map((a, idx) => `> ${String.fromCharCode(65 + idx)}. ${decodeHtml(a)}`)
.join("\\n");
return `### 🧩 Q${i + 1}: ${decodeHtml(q.question)}\\n${choices}\\n\\n`;
}).join("\\n---\\n\\n");

const header = "👋 **Thank you for opening this Pull Request!**\\n\\n🧠 **CI Trivia Time!**\\nHere are 3 random computer trivia questions to keep you entertained while CI runs.\\n*(You can reply with your guesses!)*\\n\\n";
const body = header + questions;

await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body
});