-
Notifications
You must be signed in to change notification settings - Fork 0
70 lines (53 loc) · 2.14 KB
/
deploy_dev.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
61
62
63
64
65
66
67
68
69
70
# This workflow build and push a Docker container to Google Artifact Registry
# and deploy it on Cloud Run when a PR has been approved by a reviewer.
name: 'Build and Deploy to Cloud Run'
on:
pull_request_review:
branches:
- main
types: [submitted]
env:
PROJECT_ID: ${{ secrets.PROJECT_ID }}
REGION: ${{ secrets.REGION_LOC_1 }}
SERVICE: 'map-dragon'
IMAGE_NAME: 'map-dragon_img'
GCP_CREDENTIALS: ${{ secrets.GCP_CREDENTIALS }}
jobs:
deploy:
runs-on: 'ubuntu-latest'
if: github.event.review.state == 'approved'
environment:
name: dev
permissions:
contents: 'read'
id-token: 'write'
steps:
- name: 'Checkout'
uses: 'actions/checkout@v4'
- id: 'auth'
name: 'Authenticate to Google Cloud'
uses: 'google-github-actions/auth@v2'
with:
credentials_json: '${{ env.GCP_CREDENTIALS }}'
- name: Generate .env.dev file
run: |
echo "VITE_CLIENT_ID = ${{ secrets.VITE_CLIENT_ID }}" > .env.dev
echo "VITE_SEARCH_ENDPOINT = ${{ secrets.VITE_SEARCH_ENDPOINT }}" >> .env.dev
echo "VITE_VOCAB_ENDPOINT= ${{ secrets.VITE_VOCAB_ENDPOINT }}" >> .env.dev
- name: 'Docker Auth'
run: |-
gcloud auth configure-docker '${{ env.REGION }}-docker.pkg.dev'
- name: 'Build Docker Image' # New step to build the image
run: |-
DOCKER_TAG="${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.SERVICE }}/${{ env.IMAGE_NAME }}:${{ github.sha }}"
docker build -t "${DOCKER_TAG}" --build-arg ENV=dev .
- name: 'Push Docker Image'
run: |-
DOCKER_TAG="${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.SERVICE }}/${{ env.IMAGE_NAME }}:${{ github.sha }}"
docker push "${DOCKER_TAG}"
- name: 'Deploy to Cloud Run'
uses: 'google-github-actions/deploy-cloudrun@v2'
with:
service: '${{ env.SERVICE }}'
region: '${{ env.REGION }}'
image: "${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.SERVICE }}/${{ env.IMAGE_NAME }}:${{ github.sha }}"