diff --git a/.github/workflows/getcalendar.yml b/.github/workflows/getcalendar.yml new file mode 100644 index 0000000..514ac06 --- /dev/null +++ b/.github/workflows/getcalendar.yml @@ -0,0 +1,34 @@ +name: Fetch the Google Calendar + +on: + workflow_dispatch: + # schedule: + # - cron: '01 18 * * *' + +permissions: + contents: write + +jobs: + fetch-calendar: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Curl calendar + run: | + cd static/js + echo "download calendar" + bash ../../getcalendar.sh + 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 }} diff --git a/calendar.sh b/calendar.sh new file mode 100644 index 0000000..1c7c2c2 --- /dev/null +++ b/calendar.sh @@ -0,0 +1,7 @@ +CALENDAR_ID="nerseigospses068jd57bk5ar8@group.calendar.google.com" +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" +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'