-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
109 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Pretalx Sync | ||
|
||
on: | ||
schedule: | ||
- cron: "0 1 * * *" | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@master | ||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: "20" | ||
- run: yarn install | ||
- run: yarn sync:pretalx | ||
env: | ||
PRETALX_API_KEY: ${{ secrets.PRETALX_API_KEY }} | ||
- uses: EndBug/add-and-commit@v9 | ||
with: | ||
default_author: github_actions | ||
message: "[action] Pretalx Sync" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { GetData } from '@/clients/filesystem' | ||
import { GetRooms, GetSpeakers, GetSubmissions } from '@/clients/pretalx' | ||
import fs from 'fs' | ||
|
||
async function main() { | ||
console.log('Syncing Pretalx...') | ||
await syncRooms() | ||
await syncSessions() | ||
} | ||
|
||
async function syncRooms() { | ||
if (!fs.existsSync('./data/rooms/devcon-7')) { | ||
fs.mkdirSync('./data/rooms/devcon-7') | ||
} | ||
|
||
const rooms = await GetRooms() | ||
const roomsFs = GetData('rooms/devcon-7') | ||
console.log('Rooms Pretalx', rooms.length, 'Rooms fs', roomsFs.length) | ||
|
||
console.log('Sync Rooms') | ||
for (const room of roomsFs) { | ||
if (!rooms.some((r: any) => r.id === room.id)) { | ||
console.log('- delete room', room.id) | ||
fs.unlinkSync(`./data/rooms/devcon-7/${room.id}.json`) | ||
} | ||
} | ||
|
||
for (const room of rooms) { | ||
fs.writeFileSync(`./data/rooms/devcon-7/${room.id}.json`, JSON.stringify(room, null, 2)) | ||
} | ||
|
||
console.log('Synced Pretalx Rooms') | ||
console.log('') | ||
} | ||
|
||
async function syncSessions() { | ||
const speakers = await GetSpeakers() | ||
const acceptedSpeakers: any[] = [] | ||
|
||
if (!fs.existsSync(`./data/sessions/devcon-7`)) { | ||
fs.mkdirSync(`./data/sessions/devcon-7`) | ||
} | ||
const sessions = await GetSubmissions() | ||
const sessionsFs = GetData('sessions/devcon-7') | ||
console.log('Sessions Pretalx', sessions.length, 'Sessions fs', sessionsFs.length) | ||
|
||
console.log('Sync Sessions') | ||
for (const session of sessionsFs) { | ||
if (!sessions.some((s: any) => s.id === session.id)) { | ||
console.log('- delete session', session.id) | ||
fs.unlinkSync(`./data/sessions/devcon-7/${session.id}.json`) | ||
} | ||
} | ||
|
||
for (const session of sessions) { | ||
if (session.speakers.length > 0) { | ||
acceptedSpeakers.push(...speakers.filter((s: any) => session.speakers.includes(s.id))) | ||
} | ||
|
||
fs.writeFileSync(`./data/sessions/devcon-7/${session.id}.json`, JSON.stringify(session, null, 2)) | ||
} | ||
|
||
console.log('Speakers Pretalx', speakers.length, 'Accepted Speakers', acceptedSpeakers.length) | ||
console.log('Sync Speakers') | ||
for (const speaker of acceptedSpeakers) { | ||
fs.writeFileSync(`./data/speakers/${speaker.id}.json`, JSON.stringify(speaker, null, 2)) | ||
} | ||
|
||
console.log('Synced Pretalx Schedule') | ||
console.log('') | ||
} | ||
|
||
main() | ||
.then(async () => { | ||
console.log('All done!') | ||
}) | ||
.catch(async (e) => { | ||
console.error(e) | ||
process.exit(1) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters