Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preview/calendar #14

Merged
merged 20 commits into from
Apr 19, 2024
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
38 changes: 38 additions & 0 deletions .github/workflows/getcalendar.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Fetch the Google Calendar

on:
workflow_dispatch: # only works in default branch
push:
schedule: # only works in default branch
- cron: '50 9 * * *'

permissions:
contents: write

jobs:
fetch-calendar:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Curl calendar
run: |
git config user.email "[email protected]"
git config user.name "Community Developers"
cd static/js
echo "download calendar"
bash ../../getcalendar.sh
git status
echo "preparing to push change(s)"
git add .
if git commit -m "Add updates"
then
git push
echo "Changed!"
exit 0
else
echo "No change"
true # ensure success
fi
env: # for gh
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16 changes: 16 additions & 0 deletions getcalendar.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

# Fetch calendar data; will be stored as calendar.json

CALENDAR_ID="[email protected]"
API_KEY="AIzaSyDJkXq1faq2G5NkFkFTh9Sikdpc2YXTVXs"
NOW=$(date '+%Y-%m-%dT%H:%M:%SZ')
OPTS="?key=${API_KEY}&timeMin=${NOW}&singleEvents=true&orderBy=startTime&timezone=UTC&maxResults=20"

echo "Fetching calendar data"

curl -sS -o calendar.json "https://www.googleapis.com/calendar/v3/calendars/${CALENDAR_ID}/events${OPTS}" \
-H 'accept: application/json, text/javascript, */*; q=0.01' \
-H 'origin: https://events.apache.org'

echo "Fetched data"
Loading