Skip to content

Commit 1bd95f5

Browse files
committed
UPDATE: GHA to deploy to CloudRun
1 parent 89dcc6e commit 1bd95f5

File tree

2 files changed

+68
-1
lines changed

2 files changed

+68
-1
lines changed

.github/workflows/gcr-deploy.yaml

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: deploy
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
workflow_dispatch:
9+
10+
# Environment variables available to all jobs and steps in this workflow
11+
# NOTE: these aren't really secret, but there aren't non-secret settings
12+
env:
13+
RUN_PROJECT: ${{ secrets.RUN_PROJECT }}
14+
RUN_REGION: ${{ secrets.RUN_REGION }}
15+
RUN_SERVICE: ${{ secrets.RUN_SERVICE }}
16+
17+
jobs:
18+
deploy:
19+
name: Deploy to CloudRun
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v1
25+
26+
- name: gcloud auth
27+
id: 'auth'
28+
uses: 'google-github-actions/auth@v0'
29+
with:
30+
credentials_json: '${{ secrets.GCP_SA_KEY }}'
31+
32+
# Setup gcloud CLI
33+
- name: gcloud setup
34+
uses: google-github-actions/setup-gcloud@v0
35+
36+
- name: gcloud docker-auth
37+
run: gcloud auth configure-docker
38+
39+
# Build and push image to Google Container Registry
40+
- name: Build
41+
run: |
42+
docker build \
43+
--build-arg COMMIT=${GITHUB_SHA:0:7} \
44+
--build-arg LASTMOD=$(date -u +%Y-%m-%dT%H:%M:%SZ) \
45+
--tag gcr.io/${RUN_PROJECT}/${RUN_SERVICE}:$GITHUB_SHA \
46+
.
47+
48+
- name: GCloud auth to docker
49+
run: |
50+
gcloud auth configure-docker
51+
52+
- name: Push to registry
53+
run: |
54+
docker push gcr.io/${RUN_PROJECT}/${RUN_SERVICE}:$GITHUB_SHA
55+
56+
# Deploy image to Cloud Run
57+
- name: Deploy
58+
run: |
59+
gcloud run deploy ${RUN_SERVICE} \
60+
--allow-unauthenticated \
61+
--image gcr.io/${RUN_PROJECT}/${RUN_SERVICE}:$GITHUB_SHA \
62+
--platform managed \
63+
--project ${RUN_PROJECT} \
64+
--region ${RUN_REGION}

README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,12 @@ LATER
2929
## Credits
3030

3131
[![Google CloudRun](https://www.vectorlogo.zone/logos/google_cloud_run/google_cloud_run-ar21.svg)](https://cloud.google.com/run/ "Hosting")
32+
[![Docker](https://www.vectorlogo.zone/logos/docker/docker-ar21.svg)](https://www.docker.com/ "Deployment")
3233
[![Git](https://www.vectorlogo.zone/logos/git-scm/git-scm-ar21.svg)](https://git-scm.com/ "Version control")
3334
[![Github](https://www.vectorlogo.zone/logos/github/github-ar21.svg)](https://github.com/ "Code hosting")
34-
[![Google Noto Emoji](https://www.vectorlogo.zone/logos/google/google-ar21.svg)](https://github.com/googlefonts/noto-emoji/blob/master/svg/emoji_u1f441.svg "Logo/Favicon")[![NodePing](https://www.vectorlogo.zone/logos/nodeping/nodeping-ar21.svg)](https://nodeping.com?rid=201109281250J5K3P "Uptime monitoring")
35+
[![Google Noto Emoji](https://www.vectorlogo.zone/logos/google/google-ar21.svg)](https://github.com/googlefonts/noto-emoji/blob/master/svg/emoji_u1f441.svg "Logo/Favicon")
36+
[![Node.js](https://www.vectorlogo.zone/logos/nodejs/nodejs-ar21.svg)](https://nodejs.org/ "Application Server")
37+
[![NodePing](https://www.vectorlogo.zone/logos/nodeping/nodeping-ar21.svg)](https://nodeping.com?rid=201109281250J5K3P "Uptime monitoring")
3538
[![npm](https://www.vectorlogo.zone/logos/npmjs/npmjs-ar21.svg)](https://www.npmjs.com/ "JS Package Management")
3639
[![Phosphor Icons](https://www.vectorlogo.zone/logos/phosphoricons/phosphoricons-ar21.svg)](https://phosphoricons.com/ "Toolbar icons")
3740
[![react.js](https://www.vectorlogo.zone/logos/reactjs/reactjs-ar21.svg)](https://reactjs.org/ "UI Framework")

0 commit comments

Comments
 (0)