Send a good morning message to your Google Chat webhook. The message would include the day of the week, a quote, and the author of the quote. Quote and its author is fetched using ZenQuotes API.
You can run your application in dev mode that enables live coding using below. Dev UI should be accessible at http://localhost:3005/q/dev-ui/.
./mvnw compile quarkus:dev
-
Create the JAR
./mvnw clean package -DskipTests
-
Run the JAR with specific GChat webhook URL and a time zone [optional]. By default, the the
America/Edmonton
time zone is used.java -Dzoneid="Pacific/Auckland" -Dgspace.webhook="<GCHAT-WEBHOOK-URL>" -jar target/inspirational-morning-*.jar
-
Once the JAR is running, hit the exposed ReST endpoint to send the greeting
curl --silent --request POST --location http://localhost:3005/api/greet | jq
-
Create up a Pub/Sub topic.
gcloud pubsub topics create topic-inspirational-morning
-
Create a cron job schedule for every weekday at 08:00.
gcloud scheduler jobs create pubsub schedule-job-inspirational-morning \ --schedule="0 8 * * 0-5" \ --topic=topic-inspirational-morning \ --message-body="job is triggered" \ --time-zone="Pacific/Auckland" \ --location="us-central1"
-
Deploy the application as a Cloud Function
gcloud functions deploy inspirational-morning \ --gen2 \ --allow-unauthenticated \ --trigger-topic=topic-inspirational-morning \ --region=us-central1 \ --timeout=540s \ --entry-point=io.quarkus.gcp.functions.QuarkusCloudEventsFunction \ --runtime=java17 \ --memory=256MiB \ --cpu=0.167 \ --source=target/deployment \ --set-env-vars=ZONEID="Pacific/Auckland",GSPACE_WEBHOOK="https://chat.googleapis.com/v1/spaces/SPACE_ID/messages?key=KEY&token=TOKEN"
-
[OPTIONAL] Trigger the job manually
gcloud scheduler jobs run schedule-job-inspirational-morning --location="us-central1"
-
Delete the function
gcloud functions delete inspirational-morning --region=us-central1
-
Delete the job schedule
gcloud scheduler jobs delete schedule-job-inspirational-morning --location=us-central1
-
Delete the topic
gcloud pubsub topics delete topic-inspirational-morning