Deploy #94
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: Deploy | |
on: | |
workflow_dispatch: | |
workflow_run: | |
workflows: ["Code Quality"] | |
types: | |
- completed | |
env: | |
FUNCTIONS_DIR: src/actransit_rt/functions | |
jobs: | |
deploy: | |
name: Deploy | |
runs-on: ubuntu-22.04 | |
permissions: | |
contents: 'read' | |
id-token: 'write' | |
environment: prod | |
steps: | |
- uses: 'actions/checkout@v4' | |
- id: 'auth' | |
uses: 'google-github-actions/auth@v2' | |
with: | |
service_account: 'ac-transit-rt-deploy-github-ac@tvrr-409423.iam.gserviceaccount.com' | |
workload_identity_provider: 'projects/1072483117171/locations/global/workloadIdentityPools/github/providers/actransit-rt-repo' | |
- name: 'Set up Cloud SDK' | |
uses: 'google-github-actions/setup-gcloud@v2' | |
with: | |
version: '>= 390.0.0' | |
- name: get python version | |
run: | | |
python_version=$(cat .python-version) | |
echo "python_version=${python_version}" >> $GITHUB_ENV | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.python_version }} | |
- name: setup poetry | |
run: | | |
curl -sSL https://install.python-poetry.org | python - | |
echo "$HOME/.poetry/bin" >> $GITHUB_PATH | |
poetry self add poetry-plugin-export | |
- name: load poetry install from cache | |
id: cached-poetry-dependencies | |
uses: actions/cache@v4 | |
with: | |
path: .venv | |
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }} | |
- name: install dependancies | |
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' | |
run: | | |
poetry env use "$(cat .python-version)" | |
poetry install | |
- name: export requirements | |
run: poetry export --without-hashes -f requirements.txt --output $FUNCTIONS_DIR/requirements.txt | |
- name: 'Deploy Hello' | |
run: | | |
gcloud functions deploy actransit-rt-hello \ | |
--gen2 \ | |
--region=us-west1 \ | |
--runtime=python312 \ | |
--source=$FUNCTIONS_DIR \ | |
--entry-point=hello \ | |
--concurrency=1 \ | |
--trigger-http \ | |
--no-allow-unauthenticated | |
- name: 'Deploy Snapshot' | |
env: | |
ACTRANSIT_API_TOKEN: ${{ secrets.ACTRANSIT_API_TOKEN }} | |
run: | | |
gcloud functions deploy actransit-rt-snapshot-feeds \ | |
--gen2 \ | |
--region=us-west1 \ | |
--runtime=python312 \ | |
--source=$FUNCTIONS_DIR \ | |
--entry-point=snapshot_feeds \ | |
--concurrency=1 \ | |
--trigger-http \ | |
--no-allow-unauthenticated \ | |
--set-env-vars "OUTPUT_DIR=gs://tvrr-transit-snapshots/actransit/gtfs-rt" \ | |
--set-env-vars "ACTRANSIT_API_TOKEN=$ACTRANSIT_API_TOKEN" |