Skip to content

Commit ef8fbeb

Browse files
committed
add deployment of transsect function to GCP
1 parent eead7f7 commit ef8fbeb

File tree

1 file changed

+62
-7
lines changed

1 file changed

+62
-7
lines changed

.github/workflows/deploy_function.yml

+62-7
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,15 @@ on:
5555
env:
5656
PROJECT_ID: dgds-i1000482-002
5757
GAR_LOCATION: europe-west3
58-
SERVICE: gca-report-function
58+
REPORT_SERVICE: gca-report-function
59+
REPORT_DIRECTORY: app/functions/report-python-cloud-run
60+
TRANSSECT_SERVICE: gca-transsect-function
61+
TRANSSECT_DIRECTORY: app/functions/delta-dtm-transsect-plot
5962
REPOSITORY: gca-artifacts
6063
REGION: europe-west3
6164

6265
jobs:
63-
deploy:
66+
deploy-report:
6467
# Add 'id-token' with the intended permissions for workload identity federation
6568
permissions:
6669
contents: "read"
@@ -91,10 +94,10 @@ jobs:
9194
gcloud auth print-access-token | docker login -u oauth2accesstoken --password-stdin ${{ env.GAR_LOCATION }}-docker.pkg.dev
9295
9396
- name: Build and Push Container
94-
working-directory: App/functions/report-python-cloud-run
97+
working-directory: ${{ env.REPORT_DIRECTORY }}
9598
run: |-
96-
docker build -t "${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.SERVICE }}:${{ github.sha }}" .
97-
docker push "${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.SERVICE }}:${{ github.sha }}"
99+
docker build -t "${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.REPORT_SERVICE }}:${{ github.sha }}" .
100+
docker push "${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.REPORT_SERVICE }}:${{ github.sha }}"
98101
99102
# END - Docker auth and build
100103

@@ -103,10 +106,10 @@ jobs:
103106
id: deploy
104107
uses: google-github-actions/deploy-cloudrun@v2
105108
with:
106-
service: ${{ env.SERVICE }}
109+
service: ${{ env.REPORT_SERVICE }}
107110
region: ${{ env.REGION }}
108111
# NOTE: If using a pre-built image, update the image name here
109-
image: ${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.SERVICE }}:${{ github.sha }}
112+
image: ${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.REPORT_SERVICE }}:${{ github.sha }}
110113
env_vars: |-
111114
OPENAI_API_BASE=${{ secrets.OPENAI_API_BASE }}
112115
AZURE_OPENAI_API_KEY=${{ secrets.AZURE_OPENAI_API_KEY }}
@@ -116,3 +119,55 @@ jobs:
116119
- name: Show Output
117120
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
118121
run: echo ${{ steps.deploy.outputs.url }}
122+
deploy-transsect:
123+
# Add 'id-token' with the intended permissions for workload identity federation
124+
permissions:
125+
contents: "read"
126+
id-token: "write"
127+
128+
runs-on: ubuntu-latest
129+
steps:
130+
- name: Checkout
131+
uses: actions/checkout@v2
132+
133+
# NOTE: Alternative option - authentication via credentials json
134+
- name: Google Auth
135+
id: auth
136+
uses: "google-github-actions/auth@v2"
137+
with:
138+
credentials_json: "${{ secrets.GCP_FUNCTION_CREDENTIALS }}"
139+
140+
# BEGIN - Docker auth and build (NOTE: If you already have a container image, these Docker steps can be omitted)
141+
- name: "Set up Cloud SDK"
142+
uses: "google-github-actions/setup-gcloud@v2"
143+
with:
144+
version: ">= 450.0.0"
145+
146+
# Authenticate Docker to Google Cloud Artifact Registry
147+
- name: Docker Auth
148+
id: docker-auth
149+
run: |-
150+
gcloud auth print-access-token | docker login -u oauth2accesstoken --password-stdin ${{ env.GAR_LOCATION }}-docker.pkg.dev
151+
152+
- name: Build and Push Container
153+
working-directory: ${{ env.TRANSSECT_DIRECTORY }}
154+
run: |-
155+
docker build -t "${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.TRANSSECT_SERVICE }}:${{ github.sha }}" .
156+
docker push "${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.TRANSSECT_SERVICE }}:${{ github.sha }}"
157+
158+
# END - Docker auth and build
159+
160+
- name: Deploy to Cloud Run
161+
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
162+
id: deploy
163+
uses: google-github-actions/deploy-cloudrun@v2
164+
with:
165+
service: ${{ env.TRANSSECT_SERVICE }}
166+
region: ${{ env.REGION }}
167+
# NOTE: If using a pre-built image, update the image name here
168+
image: ${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.TRANSSECT_SERVICE }}:${{ github.sha }}
169+
170+
# If required, use the Cloud Run url output in later steps
171+
- name: Show Output
172+
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
173+
run: echo ${{ steps.deploy.outputs.url }}

0 commit comments

Comments
 (0)