Skip to content

Daily CURL Request #748

Daily CURL Request

Daily CURL Request #748

Workflow file for this run

name: Daily CURL Request
on:
workflow_dispatch:
schedule:
# Runs at 0:55 AM AEST (UTC+10:00) every day.
- cron: '55 14 * * *'
jobs:
curl_request:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Calculate epoch values for today and tomorrow
id: date-calculation
run: |
# Calculate 'dateFrom' for today at the start of the day (00:00:00)
DATE_FROM=$(date -u +"%s" -d "today 00:00:00")
# Multiply by 1000 to convert seconds to milliseconds
DATE_FROM_MS=$((DATE_FROM * 1000))
# Calculate 'dateTo' for tomorrow at the start of the day (00:00:00)
DATE_TO=$(date -u +"%s" -d "tomorrow 00:00:00")
# Multiply by 1000 to convert seconds to milliseconds
DATE_TO_MS=$((DATE_TO * 1000))
# Write to the GITHUB_ENV
echo "DATE_FROM_MS=$DATE_FROM_MS" >> $GITHUB_ENV
echo "DATE_TO_MS=$DATE_TO_MS" >> $GITHUB_ENV
- name: CURL request to Queensland Events API
run: |
curl --compressed -X GET \
-H "Accept: application/json" \
"https://api.prod.aws.queensland.com/search?category=events&countryCode=au_en&dateFrom=${{ env.DATE_FROM_MS }}&dateTo=${{ env.DATE_TO_MS }}&destination=all-queensland&disabledClassificationsFilter=true&rawCategory=event" > events.json
- name: Commit events file
run: |
git config --global user.email "action@github.com"
git config --global user.name "GitHub Action"
git fetch --unshallow || true
git add events.json
count=$(jq '.hits.total.value' events.json)
summary=$(jq -r '.hits.hits[] | ._source.productName' events.json | sed 's/^/- /')
dt=$(date -u +'%Y-%m-%d')
git commit -m "${dt} : ${count} events" -m "${summary}" || exit 0
git push