build(deps): bump the ci-dependencies group with 1 update #34
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Push Events | |
on: | |
push: | |
branches: | |
- main | |
- dev | |
pull_request: | |
branches: | |
- main | |
- dev | |
concurrency: | |
group: "${{ github.head_ref || github.ref }}" | |
cancel-in-progress: true | |
jobs: | |
test: | |
name: Setup and Test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.9" | |
# cache: pip | |
# cache-dependency-path: setup.py | |
- name: Install libkrb5 for Kerberos on Linux | |
run: | | |
sudo apt install -y libkrb5-dev | |
pip install requests-kerberos | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install module | |
run: pip install .[tests] | |
- name: Test with pytest | |
run: pytest | |
deploy-dev: | |
name: Deploy to GCF - dev | |
needs: test | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/dev' | |
environment: | |
name: dev | |
permissions: | |
id-token: write | |
contents: read | |
steps: | |
- name: ⬇️ Set up code | |
uses: actions/checkout@v4 | |
- name: 🗝️ Authenticate to Google Cloud | |
id: auth | |
uses: google-github-actions/auth@v1 | |
with: | |
create_credentials_file: true | |
token_format: access_token | |
workload_identity_provider: ${{ secrets.IDENTITY_PROVIDER }} | |
service_account: ${{ secrets.SERVICE_ACCOUNT_EMAIL }} | |
- name: 🚀 Deploy to Cloud Function | |
id: deploy | |
uses: google-github-actions/deploy-cloud-functions@v1 | |
with: | |
name: wmrc-skid | |
runtime: python39 | |
entry_point: main | |
source_dir: src/wmrc | |
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 | |
deploy_timeout: 600 | |
memory_mb: 512 | |
timeout: "9m" | |
env_vars: STORAGE_BUCKET=${{secrets.STORAGE_BUCKET}} | |
secret_volumes: | | |
/secrets/app/secrets.json=${{secrets.PROJECT_ID}}/skid-secrets | |
- name: 📥 Create PubSub topic | |
run: | | |
if [ ! "$(gcloud pubsub topics list | grep monday-morning-topic)" ]; then | |
gcloud pubsub topics create monday-morning-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 wmrc-skid bot once a week on monday morning" \ | |
--schedule="0 9 * * 1" \ | |
--time-zone=America/Denver \ | |
--location=us-central1 \ | |
--topic=monday-morning-topic \ | |
--message-body='{"run": "now"}' \ | |
--quiet | |
else | |
gcloud scheduler jobs update pubsub monday-morning \ | |
--description="Trigger the wmrc-skid bot once a week on monday morning" \ | |
--schedule="0 9 * * 1" \ | |
--time-zone=America/Denver \ | |
--location=us-central1 \ | |
--topic=monday-morning-topic \ | |
--message-body='{"run": "now"}' \ | |
--quiet | |
fi | |
deploy-prod: | |
name: Deploy to GCF - prod | |
needs: test | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/main' | |
environment: | |
name: prod | |
permissions: | |
id-token: write | |
contents: read | |
steps: | |
- name: ⬇️ Set up code | |
uses: actions/checkout@v4 | |
- name: 🗝️ Authenticate to Google Cloud | |
id: auth | |
uses: google-github-actions/auth@v1 | |
with: | |
create_credentials_file: true | |
token_format: access_token | |
workload_identity_provider: ${{ secrets.IDENTITY_PROVIDER }} | |
service_account: ${{ secrets.SERVICE_ACCOUNT_EMAIL }} | |
- name: 🚀 Deploy to Cloud Function | |
id: deploy | |
uses: google-github-actions/deploy-cloud-functions@v1 | |
with: | |
name: wmrc-skid | |
runtime: python39 | |
entry_point: main | |
source_dir: src/wmrc | |
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/first-of-the-month-topic | |
deploy_timeout: 600 | |
memory_mb: 512 | |
timeout: "9m" | |
env_vars: STORAGE_BUCKET=${{secrets.STORAGE_BUCKET}} | |
secret_volumes: | | |
/secrets/app/secrets.json=${{secrets.PROJECT_ID}}/skid-secrets | |
- name: 📥 Create PubSub topic | |
run: | | |
if [ ! "$(gcloud pubsub topics list | grep first-of-the-month-topic)" ]; then | |
gcloud pubsub topics create first-of-the-month-topic --quiet | |
fi | |
- name: 🕰️ Create Cloud Scheduler | |
run: | | |
if [ ! "$(gcloud scheduler jobs list --location=us-central1 | grep first-of-the-month)" ]; then | |
gcloud scheduler jobs create pubsub first-of-the-month \ | |
--description="Trigger the wmrc-skid bot on the first day of the month" \ | |
--schedule="0 9 1 * *" \ | |
--time-zone=America/Denver \ | |
--location=us-central1 \ | |
--topic=first-of-the-month-topic \ | |
--message-body='{"run": "now"}' \ | |
--quiet | |
else | |
gcloud scheduler jobs update pubsub first-of-the-month \ | |
--description="Trigger the wmrc-skid bot on the first day of the month" \ | |
--schedule="0 9 1 * *" \ | |
--time-zone=America/Denver \ | |
--location=us-central1 \ | |
--topic=first-of-the-month-topic \ | |
--message-body='{"run": "now"}' \ | |
--quiet | |
fi | |
- name: 🔔 Create deployment notification | |
uses: agrc/service-now-worknote-action@v1 | |
with: | |
repo-token: ${{ github.token }} | |
username: ${{ secrets.SN_USERNAME }} | |
password: ${{ secrets.SN_PASSWORD }} | |
instance-name: ${{ secrets.SN_INSTANCE }} | |
table-name: ${{ secrets.SN_TABLE }} | |
system-id: ${{ secrets.SN_SYS_ID }} |