-
Notifications
You must be signed in to change notification settings - Fork 2
101 lines (83 loc) · 2.71 KB
/
deploy-to-gcr.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
name: Google Cloud Run Deploy
on:
push:
branches:
- development
env:
PROJECT_ID: ${{ secrets.GCR_PROJECT }}
RUN_REGION: us-central1
SERVICE_NAME: reservaksin-fe-user
jobs:
build:
name: Build React App
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v2
- name: Setup Node.js (NPM)
uses: actions/setup-node@v2
with:
node-version: "14.x"
- name: Use cached node_modules
uses: actions/cache@v2
with:
path: ~/.npm
key: npm-${{ hashFiles('./package-lock.json') }}
restore-keys: |
npm-
- name: Install dependencies
run: npm ci --ignore-scripts
- name: Create env file
run: |
touch .env
echo REACT_APP_GMAPS_GEOCODE_API_KEY=${{ secrets.GMAPS_GEOCODE_API_KEY }} >> .env
echo REACT_APP_RESERVAKSIN_API_URL=${{ secrets.RESERVAKSIN_API_URL }} >> .env
cat .env
- name: docker login
env:
DOCKER_USER: ${{ secrets.DOCKER_HUB_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }}
run: |
docker login -u $DOCKER_USER -p $DOCKER_PASSWORD
- name: docker build
run: |
docker build -t fadhilansyah25/reservaksin-fe-user:latest -f ./docker/Dockerfile .
- name: docker push images
run: |
docker push fadhilansyah25/reservaksin-fe-user:latest
deploy-gcr:
name: Deploy to GCR
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v2
- name: docker pull images
run: |
docker pull fadhilansyah25/reservaksin-fe-user:latest
- name: docker tagging images
run: |
docker tag fadhilansyah25/reservaksin-fe-user:latest gcr.io/$PROJECT_ID/$SERVICE_NAME:$GITHUB_SHA
- name: Setup GCloud Auth
id: auth
uses: google-github-actions/auth@v0
with:
credentials_json: ${{ secrets.GCR_SA_KEY }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v0.2.1
# Configure docker to use the gcloud command-line tool as a credential helper
- run: |
gcloud auth configure-docker -q
# push image to Google Container Registry
- name: Push images
run: |
docker push gcr.io/$PROJECT_ID/$SERVICE_NAME:$GITHUB_SHA
# Deploy image to Cloud Run
- name: Deploy GCR
run: |-
gcloud run deploy "$SERVICE_NAME" \
--quiet \
--region "$RUN_REGION" \
--image "gcr.io/$PROJECT_ID/$SERVICE_NAME:$GITHUB_SHA" \
--platform "managed" \
--allow-unauthenticated