Skip to content

Commit 0b80a51

Browse files
committed
VAMOAROMPERTODO2
1 parent 9e0cf38 commit 0b80a51

1 file changed

Lines changed: 41 additions & 3 deletions

File tree

.github/workflows/google-cloudrun-docker.yml

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
name: Build and Deploy to Cloud Run
22
on:
3-
push:
4-
#pull_request:
3+
push: #pull_request:
54
workflow_dispatch:
65

76
env:
87
PROJECT_ID: ${{ vars.GCP_PROJECT_ID }}
98
PROJECT_REGION: ${{ vars.GCP_PROJECT_REGION }}
109
SERVICE_NAME: ${{ vars.GCP_SERVICE_API_NAME }}
10+
JOB_NAME: ${{ vars.GCP_SERVICE_API_NAME }}-update-groups
1111
ARTIFACT_REGISTRY: ${{ vars.GCP_ARTIFACT_REGISTRY }}
1212

1313
jobs:
@@ -44,7 +44,7 @@ jobs:
4444
docker push $TAG
4545
4646
deploy-to-cloud-run:
47-
name: Deploy to Cloud Run
47+
name: Deploy Service to Cloud Run
4848
needs: build-and-push
4949
runs-on: ubuntu-latest
5050
environment: GCP-Rozen
@@ -89,3 +89,41 @@ jobs:
8989
--set-env-vars=WEBHOOK_URL=${{ env.URL }} \
9090
--platform managed \
9191
--allow-unauthenticated
92+
93+
deploy-cron-job-to-cloud-run:
94+
name: Deploy CronJob to Cloud Run
95+
needs: build-and-push
96+
runs-on: ubuntu-latest
97+
environment: GCP-Rozen
98+
if: github.event_name == 'push'
99+
permissions:
100+
contents: 'read'
101+
id-token: 'write'
102+
103+
steps:
104+
- name: Authenticate Cloud CLI
105+
uses: 'google-github-actions/auth@v2'
106+
with:
107+
credentials_json: ${{ secrets.GCP_SA_KEY }}
108+
109+
- name: Set up Cloud SDK
110+
uses: 'google-github-actions/setup-gcloud@v2'
111+
112+
- name: Define image tag for deployment
113+
run: echo "TAG=${{ env.PROJECT_REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.ARTIFACT_REGISTRY }}/${{ env.SERVICE_NAME }}:${{ github.sha }}" >> $GITHUB_ENV
114+
115+
- name: Deploy Cron Job to Cloud Run
116+
run: |-
117+
gcloud run jobs deploy ${{ env.JOB_NAME }} \
118+
--image $TAG \
119+
--region ${{ env.PROJECT_REGION }} \
120+
--command=python \
121+
--args=cron.py \
122+
--schedule="0 0 * * *" \
123+
--time-zone="America/Argentina/Buenos_Aires" \
124+
--service-account ${{ vars.GCP_SA_EMAIL }} \
125+
--set-secrets=TELEGRAM_BOT_TOKEN=${{ vars.GCP_SECRET_TG_BOT_TOKEN }}:latest \
126+
--set-secrets=DB_USER=${{ vars.GCP_SECRET_DB_USER }}:latest \
127+
--set-secrets=DB_PASSWORD=${{ vars.GCP_SECRET_DB_PASSWORD }}:latest \
128+
--set-secrets=DB_URL=${{ vars.GCP_SECRET_DB_URL }}:latest \
129+
--set-env-vars=DB_PORT=${{ vars.GCP_DB_PORT }}

0 commit comments

Comments
 (0)