Skip to content

Commit 3e22544

Browse files
theScriptingEngineertheScriptingEngineer
authored andcommitted
Merge branch 'protobuf' of https://github.com/theScriptingEngineer/bucklingAPI into protobuf
2 parents bf24d1f + 551140e commit 3e22544

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

.github/workflows/development.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Docker Image CI
2+
3+
on:
4+
push:
5+
branches: [ "protobuf" ]
6+
7+
env:
8+
SERVICE: bucklingapitest
9+
REGION: europe-west1
10+
11+
jobs:
12+
build:
13+
name: build
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v3
18+
- name: Build the Docker image
19+
run: docker build . --file dockerfile --tag ${{env.REGION}}-docker.pkg.dev/${{secrets.GOOGLE_REPO_NAME}}/bucklingapitest/bucklingapiprotobuf:latest
20+
# END - Build the Docker image
21+
22+
# from: https://github.com/google-github-actions/auth#setting-up-workload-identity-federation
23+
# I took the authentication via "Service Account Key JSON" because it is very similar to the CLI on a local machine
24+
# Had to enable the "IAM Service Account Credentials API" to allow to hand out short lived tokens. Can be found by searching for "Service Account Credentials API" in the console GUI
25+
# I had to add the container registry service account as a principle to itself with the "Service Account Token Creator" role, otherwise the service account was not permitted
26+
- id: 'auth'
27+
name: 'Authenticate to Google Cloud'
28+
uses: 'google-github-actions/auth@v2'
29+
with:
30+
credentials_json: '${{ secrets.GOOGLE_ARTIFACTS_CREDENTIALS }}'
31+
token_format: 'access_token'
32+
33+
# This example runs "docker login" directly to Container Registry.
34+
- run: |-
35+
echo '${{ steps.auth.outputs.access_token }}' | docker login -u oauth2accesstoken --password-stdin https://${{env.REGION}}-docker.pkg.dev
36+
- name: Docker push
37+
run: docker push ${{env.REGION}}-docker.pkg.dev/${{secrets.GOOGLE_REPO_NAME}}/bucklingapitest/bucklingapiprotobuf:latest
38+
39+
# END - Auth and push docker container to google container registry
40+
41+
deploy:
42+
needs: build
43+
name: deploy
44+
runs-on: ubuntu-latest
45+
46+
steps:
47+
- uses: actions/checkout@v3
48+
49+
# from https://github.com/google-github-actions/deploy-cloudrun#credentials
50+
- id: 'authCloudRun'
51+
uses: 'google-github-actions/auth@v2'
52+
with:
53+
credentials_json: '${{ secrets.GOOGLE_CLOUDRUN_CREDENTIALS }}'
54+
55+
# docs: https://github.com/marketplace/actions/deploy-to-cloud-run
56+
- name: 'Deploy to Cloud Run'
57+
uses: 'google-github-actions/deploy-cloudrun@v2'
58+
with:
59+
image: '${{env.REGION}}-docker.pkg.dev/${{secrets.GOOGLE_REPO_NAME}}/bucklingapitest/bucklingapiprotobuf:latest'
60+
service: '${{env.SERVICE}}'
61+
region: '${{env.REGION}}'

0 commit comments

Comments
 (0)