-
Notifications
You must be signed in to change notification settings - Fork 0
61 lines (52 loc) · 1.67 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
on:
push:
branches:
- main
name: Deploy to production
env:
PROJECT_ID: ${{ secrets.GCP_PROJECT }}
SERVICE: useless-interface
REGION: us-central1
MAX_INSTANCE_LIMIT: 2
MAX_CONCURRENCY: 100
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
jobs:
deploy_to_cloud_run:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Cloud SDK
uses: google-github-actions/setup-gcloud@v0.2.0
with:
project_id: ${{ env.PROJECT_ID }}
service_account_key: ${{ secrets.GCP_SA_KEY }}
- name: Authorize Docker push
run: gcloud auth configure-docker
- name: Build and Push Container
run: |-
docker build -t gcr.io/${{ env.PROJECT_ID }}/${{ env.SERVICE }} .
docker push gcr.io/${{ env.PROJECT_ID }}/${{ env.SERVICE }}
- name: Deploy to Cloud Run
run: |-
gcloud run deploy ${{ env.SERVICE }} \
--region ${{ env.REGION }} \
--image gcr.io/${{ env.PROJECT_ID }}/${{ env.SERVICE }} \
--platform "managed" \
--max-instances ${{ env.MAX_INSTANCE_LIMIT }} \
--concurrency ${{ env.MAX_CONCURRENCY }} \
--quiet
- name: Delete old images
run: |-
gcloud container images list-tags gcr.io/${{ env.PROJECT_ID }}/${{ env.SERVICE }} \
--filter='-tags:*' \
--format='get(digest)' \
| awk '{print "gcr.io/${{ env.PROJECT_ID }}/${{ env.SERVICE }}@" $1}' \
| xargs gcloud container images delete --quiet
#deploy_to_fly:
#runs-on: ubuntu-latest
#steps:
#- uses: actions/checkout@v2
#- uses: superfly/flyctl-actions@1.1
#with:
#args: "deploy"