-
Notifications
You must be signed in to change notification settings - Fork 0
52 lines (44 loc) · 1.59 KB
/
toGoogle.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
name: Build and Deploy to Cloud Run
on:
push:
branches:
- main
jobs:
deploy:
permissions:
contents: 'read'
id-token: 'write'
runs-on: ubuntu-latest
environment: GCR
env:
PROJECT_ID: ${{ secrets.PROJECT_ID }}
GAR_LOCATION: ${{ secrets.GAR_LOCATION }}
REPOSITORY: ${{ secrets.REPOSITORY }}
SERVICE: image-converter
REGION: ${{ secrets.GAR_LOCATION }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Google Auth
id: auth
uses: 'google-github-actions/auth@v2'
with:
credentials_json: '${{ secrets.GCP_CREDENTIALS }}'
token_format: 'access_token'
- name: Docker Auth
run: |-
gcloud auth configure-docker "${{ env.GAR_LOCATION }}-docker.pkg.dev"
- name: Build and Push Container
run: |-
docker build -t "${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.SERVICE }}:${{ github.sha }}" ./
docker push "${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.SERVICE }}:${{ github.sha }}"
- name: Deploy to Cloud Run
run: |-
gcloud run deploy ${{ env.SERVICE }} \
--image=${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.SERVICE }}:${{ github.sha }} \
--region=${{ env.REGION }} \
--max-instances=3 \
--platform=managed \
--allow-unauthenticated
- name: Show Output
run: echo "Deployment completed"