Skip to content

Commit

Permalink
ci: try deploying validate as its own function
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobdadams committed Aug 8, 2024
1 parent 37a8bce commit 1e86141
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 4 deletions.
49 changes: 46 additions & 3 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ env:
SCHEDULE_NAME: saturday-evening
SCHEDULE_CRON: 0 22 * * 6
SCHEDULE_DESCRIPTION: Trigger the wmrc-skid bot every saturday evening at 10pm
VALIDATOR_SCHEDULE_NAME: validator
VALIDATOR_SCHEDULE_CRON: 0 8 1 4-6 *
VALIDATOR_SCHEDULE_DESCRIPTION: Trigger the wmrc validation bot every 1st of April, May, and June at 8am

concurrency:
group: "${{ github.head_ref || github.ref }}"
Expand Down Expand Up @@ -75,7 +78,7 @@ jobs:
workload_identity_provider: ${{ secrets.IDENTITY_PROVIDER }}
service_account: ${{ secrets.SERVICE_ACCOUNT_EMAIL }}

- name: 🚀 Deploy to Cloud Function
- name: 🚀 Deploy Main Cloud Function
id: deploy
uses: google-github-actions/deploy-cloud-functions@v3
timeout-minutes: 15
Expand All @@ -95,13 +98,13 @@ jobs:
max_instance_count: 1
event_trigger_retry: false

- name: 📥 Create PubSub topic
- name: 📥 Create Main PubSub topic
run: |
if [ ! "$(gcloud pubsub topics list | grep $SCHEDULE_NAME-topic)" ]; then
gcloud pubsub topics create $SCHEDULE_NAME-topic --quiet
fi
- name: 🕰️ Create Cloud Scheduler
- name: 🕰️ Create Main Cloud Scheduler
run: |
for i in $(gcloud scheduler jobs list --location=us-central1 --uri); do
gcloud scheduler jobs delete $i --quiet
Expand All @@ -115,6 +118,46 @@ jobs:
--message-body='{"run": "now"}' \
--quiet
- name: 🚀 Deploy Validator Cloud Function
id: deploy-validator
uses: google-github-actions/deploy-cloud-functions@v3
timeout-minutes: 15
with:
name: wmrc-skid-validator
runtime: python311
entry_point: validate
source_dir: src/wmrc
service_account: cloud-function-sa@${{ secrets.PROJECT_ID }}.iam.gserviceaccount.com
event_trigger_type: google.cloud.pubsub.topic.v1.messagePublished
event_trigger_pubsub_topic: projects/${{ secrets.PROJECT_ID }}/topics/${{ env.VALIDATOR_SCHEDULE_NAME }}-topic
memory: ${{ env.CLOUD_FUNCTION_MEMORY }}
service_timeout: ${{ env.CLOUD_FUNCTION_RUN_TIMEOUT }}
environment_variables: STORAGE_BUCKET=${{secrets.STORAGE_BUCKET}}
secrets: |
/secrets/app/secrets.json=${{secrets.PROJECT_ID}}/skid-secrets
max_instance_count: 1
event_trigger_retry: false

- name: 📥 Create Validator PubSub topic
run: |
if [ ! "$(gcloud pubsub topics list | grep $VALIDATOR_SCHEDULE_NAME-topic)" ]; then
gcloud pubsub topics create $VALIDATOR_SCHEDULE_NAME-topic --quiet
fi
- name: 🕰️ Create Validator Cloud Scheduler
run: |
for i in $(gcloud scheduler jobs list --location=us-central1 --uri); do
gcloud scheduler jobs delete $i --quiet
done
gcloud scheduler jobs create pubsub $VALIDATOR_SCHEDULE_NAME \
--description="$VALIDATOR_SCHEDULE_DESCRIPTION" \
--schedule="$VALIDATOR_SCHEDULE_CRON" \
--time-zone=America/Denver \
--location=us-central1 \
--topic=$VALIDATOR_SCHEDULE_NAME-topic \
--message-body='{"run": "now"}' \
--quiet
deploy-prod:
name: Deploy to GCF - prod
needs: test
Expand Down
2 changes: 1 addition & 1 deletion src/wmrc/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
SENDGRID_SETTINGS = { #: Settings for SendGridHandler
"from_address": "noreply@utah.gov",
"to_addresses": [
# "jdadams@utah.gov",
"jdadams@utah.gov",
# "stevienorcross@utah.gov",
# "gerardorodriguez@utah.gov",
# "rachelboyer@utah.gov",
Expand Down

0 comments on commit 1e86141

Please sign in to comment.