deps: bump agrc-supervisor from 3.0.3 to 3.1.0 in the safe-dependencies group #2
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 | |
env: | |
CLOUD_FUNCTION_MEMORY: 512M | |
CLOUD_FUCNTION_RUN_TIMEOUT: 240s | |
SCHEDULE_NAME: monday-morning | |
SCHEDULE_CRON: 0 9 * * 1 | |
SCHEDULE_DESCRIPTION: "Trigger the projectname-skid bot once a week on monday morning" | |
concurrency: | |
group: "${{ github.head_ref || github.ref }}" | |
cancel-in-progress: true | |
jobs: | |
test: | |
name: Setup and Test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
show-progress: false | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.11 | |
cache: pip | |
cache-dependency-path: setup.py | |
- name: Install libkrb5 for Kerberos on Linux | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y libkrb5-dev | |
- name: Install module | |
run: pip install .[tests] | |
- name: Test with pytest | |
run: pytest | |
deploy-dev: | |
name: Deploy to GCF | |
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@v2 | |
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@v3 | |
timeout-minutes: 15 | |
with: | |
name: projectname-skid | |
runtime: python311 | |
entry_point: subscribe | |
source_dir: src/projectname | |
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.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 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 | |
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 $SCHEDULE_NAME \ | |
--description="$SCHEDULE_DESCRIPTION" \ | |
--schedule="$SCHEDULE_CRON" \ | |
--time-zone=America/Denver \ | |
--location=us-central1 \ | |
--topic=$SCHEDULE_NAME-topic \ | |
--message-body='foo' \ | |
--quiet | |
deploy-prod: | |
name: Deploy to GCF | |
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@v2 | |
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@v3 | |
timeout-minutes: 15 | |
with: | |
name: projectname-skid | |
runtime: python311 | |
entry_point: main | |
source_dir: src/projectname | |
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.SCHEDULE_NAME }}-topic | |
memory: ${{ env.CLOUD_FUNCTION_MEMORY }} | |
service_timeout: ${{ env.CLOUD_FUNCTION_RUN_TIMEOUT }} | |
environment_variables: STORAGE_BUCKET=${{secrets.STORAGE_BUCKET}} | |
secrets: | | |
/secrets/ftp/known_hosts=${{secrets.PROJECT_ID}}/known_hosts | |
/secrets/app/secrets.json=${{secrets.PROJECT_ID}}/skid-secrets | |
max_instance_count: 1 | |
event_trigger_retry: false | |
- name: 📥 Create 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 | |
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 $SCHEDULE_NAME \ | |
--description="$SCHEDULE_DESCRIPTION" \ | |
--schedule="$SCHEDULE_CRON" \ | |
--time-zone=America/Denver \ | |
--location=us-central1 \ | |
--topic=$SCHEDULE_NAME-topic \ | |
--message-body='{"run": "now"}' \ | |
--quiet |