Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
61cc199
Add schedule to redeploy every nigth at 02:00
sapnilaa Jan 15, 2026
a7f1ae5
Add function which checks if new event is added in peoply
sapnilaa Jan 21, 2026
bebddf6
Compare eventId for redeployment instead of event date
sapnilaa Jan 22, 2026
3c3ac50
Reset ci.yml-file
sapnilaa Jan 23, 2026
76ba2d7
Create new workflow file for checking events on Peoply
sapnilaa Jan 23, 2026
af90f05
Update ci.yml to also deploy if new event is found in Peoply
sapnilaa Jan 23, 2026
dc9cc60
Fix typo in fetch-events.js
sapnilaa Jan 23, 2026
fbcb340
Add permissions with least privileges
sapnilaa Jan 23, 2026
3befba1
Fix process exit 1 to 0 in catch block
sapnilaa Jan 23, 2026
7a18e41
Change ref branch for event workflow to this one for testing
sapnilaa Jan 23, 2026
105a0c7
Fix indentation and missing cron string in .yml file for event check
sapnilaa Jan 23, 2026
bc1d03b
Add null arg in stringify method
sapnilaa Jan 23, 2026
f7b30a6
Test workflow visibility
sapnilaa Jan 23, 2026
caa1bd1
Delete test workflow and add continue on error in ci.yml
sapnilaa Jan 23, 2026
c3a33d1
Remove continue-on-error: true from ci.yml
sapnilaa Jan 23, 2026
c1a9178
Update check-update.yml
sapnilaa Jan 23, 2026
cac2e83
Add this branch for testing as branch in ci.yml
sapnilaa Jan 23, 2026
1b68e01
Revert branches to only master in ci.yml
sapnilaa Jan 23, 2026
1600ed0
Add all branches on push in check-update.yml
sapnilaa Jan 23, 2026
214fc4b
Update check-update.yml for production and add eventId to eventId.txt
sapnilaa Jan 23, 2026
5639cfa
Update check-update.yml for production (forgot to add :) )
sapnilaa Jan 23, 2026
d4c4883
Replace version tag with hash for workflow-dispatch
sapnilaa Jan 23, 2026
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
31 changes: 29 additions & 2 deletions .github/fetch-events.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,38 @@ const params = new URLSearchParams({
});

const url = `${peoplyUrl}?${params}`;
const eventIdFile = "_data/eventId.txt";

let prevEventId = "";

if (fs.existsSync(eventIdFile)) {
prevEventId = fs.readFileSync(eventIdFile, "utf-8").trim();
};

fetch(url)
.then((res) => res.json())
.then((data) => {
console.log("Fetched events:", data);

if (!data || data.length === 0) {
console.log("No data returned from Peoply.")
process.exit(0);
};

// Accesss latest event ID
const latestEvent = data[0];
const latestEventId = latestEvent.id;

// Stop if no new event
if (latestEventId === prevEventId) {
console.log("No new events in Peoply.");
process.exit(0);
};

// New event found
console.log("New event added in Peoply.");
fs.writeFileSync(eventIdFile, latestEventId);

// Adjust event time to follow timezone in Norway:
const updatedData = data.map(event => {
const date = new Date(event.startDate);
Expand All @@ -23,10 +49,11 @@ fetch(url)
return {...event, startDate: updatedStartDate };
})

fs.writeFileSync("_data/events.json", JSON.stringify(updatedData, 2));
fs.writeFileSync("_data/events.json", JSON.stringify(updatedData, null, 2));
console.log("Events written to _data/events.json");
process.exit(1);
})
.catch((err) => {
console.error("Failed to fetch events:", err);
process.exit(1);
process.exit(0);
});
35 changes: 35 additions & 0 deletions .github/workflows/check-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Check for new events on Peoply

permissions:
contents: read
actions: write

on:
workflow_dispatch:
schedule:
- cron: "0 2 * * *"

jobs:
check-events:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "18"

- name: Run Peoply event check
id: check
run: node .github/fetch-events.js
continue-on-error: true

- name: Trigger main build workflow
if: steps.check.conclusion == 'failure'
uses: benc-uk/workflow-dispatch@e2e5e9a103e331dad343f381a29e654aea3cf8fc
with:
workflow: Build and Deploy Jekyll site
ref: master
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ jobs:
needs: build
if: >-
github.event_name == 'push' &&
(github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
(github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') ||
github.event_name == 'workflow_dispatch'
steps:
- name: Deploy to GitHub Pages
id: deployment
Expand Down
1 change: 1 addition & 0 deletions _data/eventId.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
29b91519-0d07-4d5f-abc5-5b9f1d6ddf59