Skip to content

Commit

Permalink
ci: update actions, gcp prep, dependabot
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobdadams committed Oct 4, 2023
1 parent 65ab160 commit 0666a90
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 33 deletions.
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: monthly
- package-ecosystem: pip
directory: /
schedule:
interval: monthly
71 changes: 38 additions & 33 deletions .github/workflows/ci.yml → .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ jobs:

steps:
- name: Set up Python
uses: actions/setup-python@v3
uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: "3.9"
# cache: pip
# cache-dependency-path: setup.py

- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
show-progress: false

- name: Install module
run: pip install .[tests]
Expand All @@ -49,11 +51,13 @@ jobs:

steps:
- name: ⬇️ Set up code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
show-progress: false

- name: 🗝️ Authenticate to Google Cloud
id: auth
uses: google-github-actions/auth@v0
uses: google-github-actions/auth@v1
with:
create_credentials_file: true
token_format: access_token
Expand All @@ -62,15 +66,15 @@ jobs:

- name: 🚀 Deploy to Cloud Function
id: deploy
uses: google-github-actions/deploy-cloud-functions@v0
uses: google-github-actions/deploy-cloud-functions@v1
with:
name: projectname-skid
runtime: python38
name: nfhl-skid
runtime: python39
entry_point: main
source_dir: src/skidname
source_dir: src/nfhl
service_account_email: cloud-function-sa@${{ secrets.PROJECT_ID }}.iam.gserviceaccount.com
event_trigger_type: providers/cloud.pubsub/eventTypes/topic.publish
event_trigger_resource: projects/${{ secrets.PROJECT_ID }}/topics/monday-morning-topic
event_trigger_resource: projects/${{ secrets.PROJECT_ID }}/topics/saturday-night-topic
deploy_timeout: 600
memory_mb: 512
timeout: 240
Expand All @@ -80,28 +84,28 @@ jobs:
- name: 📥 Create PubSub topic
run: |
if [ ! "$(gcloud pubsub topics list | grep monday-morning-topic)" ]; then
gcloud pubsub topics create monday-morning-topic --quiet
if [ ! "$(gcloud pubsub topics list | grep saturday-night-topic)" ]; then
gcloud pubsub topics create saturday-night-topic --quiet
fi
- name: 🕰️ Create Cloud Scheduler
run: |
if [ ! "$(gcloud scheduler jobs list --location=us-central1 | grep monday-morning)" ]; then
gcloud scheduler jobs create pubsub monday-morning \
--description="Trigger the projectname-skid bot once a week on monday morning" \
--schedule="0 9 * * 1" \
--description="Trigger the nfhl-skid bot once a week on monday morning" \
--schedule="0 23 * * 6" \
--time-zone=America/Denver \
--location=us-central1 \
--topic=monday-morning-topic \
--topic=saturday-night-topic \
--message-body='{"run": "now"}' \
--quiet
else
gcloud scheduler jobs update pubsub monday-morning \
--description="Trigger the projectname-skid bot once a week on monday morning" \
--schedule="0 9 * * 1" \
--description="Trigger the nfhl-skid bot once a week on monday morning" \
--schedule="0 23 * * 6" \
--time-zone=America/Denver \
--location=us-central1 \
--topic=monday-morning-topic \
--topic=saturday-night-topic \
--message-body='{"run": "now"}' \
--quiet
fi
Expand All @@ -119,11 +123,13 @@ jobs:

steps:
- name: ⬇️ Set up code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
show-progress: false

- name: 🗝️ Authenticate to Google Cloud
id: auth
uses: google-github-actions/auth@v0
uses: google-github-actions/auth@v1
with:
create_credentials_file: true
token_format: access_token
Expand All @@ -132,47 +138,46 @@ jobs:

- name: 🚀 Deploy to Cloud Function
id: deploy
uses: google-github-actions/deploy-cloud-functions@v0
uses: google-github-actions/deploy-cloud-functions@v1
with:
name: projectname-skid
runtime: python38
name: nfhl-skid
runtime: python39
entry_point: main
source_dir: src/projectname
service_account_email: cloud-function-sa@${{ secrets.PROJECT_ID }}.iam.gserviceaccount.com
event_trigger_type: providers/cloud.pubsub/eventTypes/topic.publish
event_trigger_resource: projects/${{ secrets.PROJECT_ID }}/topics/monday-morning-topic
event_trigger_resource: projects/${{ secrets.PROJECT_ID }}/topics/saturday-night-topic
deploy_timeout: 600
memory_mb: 512
timeout: 240
env_vars: STORAGE_BUCKET=${{secrets.STORAGE_BUCKET}}
secret_volumes: |
/secrets/app/secrets.json=${{secrets.PROJECT_ID}}/app_secrets
/secrets/ftp/known_hosts=${{secrets.PROJECT_ID}}/known_hosts
- name: 📥 Create PubSub topic
run: |
if [ ! "$(gcloud pubsub topics list | grep monday-morning-topic)" ]; then
gcloud pubsub topics create monday-morning-topic --quiet
if [ ! "$(gcloud pubsub topics list | grep saturday-night-topic)" ]; then
gcloud pubsub topics create saturday-night-topic --quiet
fi
- name: 🕰️ Create Cloud Scheduler
run: |
if [ ! "$(gcloud scheduler jobs list --location=us-central1 | grep monday-morning)" ]; then
gcloud scheduler jobs create pubsub monday-morning \
--description="Trigger the projectname-skid bot once a week on monday morning" \
--schedule="0 9 * * 1" \
--description="Trigger the nfhl-skid bot once a week on monday morning" \
--schedule="0 23 * * 6" \
--time-zone=America/Denver \
--location=us-central1 \
--topic=monday-morning-topic \
--topic=saturday-night-topic \
--message-body='{"run": "now"}' \
--quiet
else
gcloud scheduler jobs update pubsub monday-morning \
--description="Trigger the projectname-skid bot once a week on monday morning" \
--schedule="0 9 * * 1" \
--description="Trigger the nfhl-skid bot once a week on monday morning" \
--schedule="0 23 * * 6" \
--time-zone=America/Denver \
--location=us-central1 \
--topic=monday-morning-topic \
--topic=saturday-night-topic \
--message-body='{"run": "now"}' \
--quiet
fi

0 comments on commit 0666a90

Please sign in to comment.