-
Notifications
You must be signed in to change notification settings - Fork 10
115 lines (113 loc) · 3.85 KB
/
inspection-report.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
name: inspection-report
on:
push:
branches:
- "main"
create:
tags:
- "*"
# workflow_dispatch:
# branches:
# - "*"
# tags:
# - "*"
jobs:
check_env:
runs-on: ubuntu-latest
container: alpine:latest
steps:
- id: ref_check
run: |
echo "Running on branch ${{ github.ref }}"
if [ "${{ github.ref }}" = "refs/heads/main" ]; then
echo "::set-output name=env_name::staging"
elif [[ "${{ github.ref }}" == "refs/tags/"* ]]; then
echo "::set-output name=env_name::preview"
else
echo "::set-output name=env_name::development"
fi
outputs:
env_name: ${{ steps.ref_check.outputs.env_name }}
build:
needs: [check_env]
container:
image: node:16-slim
runs-on: ubuntu-latest
environment: ${{ needs.check_env.outputs.env_name }}
steps:
- name: Setup repo
uses: actions/checkout@v3
- name: Setup Nodejs with yarn caching
uses: actions/setup-node@v2
with:
node-version: "16"
cache: yarn
- name: Build
shell: bash
env:
REACT_APP_API_DOMAIN: ${{ secrets.API_DOMAIN }}
REACT_APP_AUTH_AUDIENCE: ${{ secrets.AUTH_AUDIENCE }}
REACT_APP_AUTH_CLIENT_ID: ${{ secrets.AUTH_CLIENT_ID }}
REACT_APP_AUTH_DOMAIN: ${{ secrets.AUTH_DOMAIN }}
REACT_APP_BRAND: Monk
REACT_APP_LOGO: https://avatars.githubusercontent.com/u/56727645
REACT_APP_FAVICON: "%PUBLIC_URL%/favicon.png"
REACT_APP_PRIMARY_COLOR_LIGHT: "#274B9F"
REACT_APP_PRIMARY_COLOR_DARK: "#2B52BE"
run: |
yarn install
cd services/inspection-report
yarn install
yarn run build
- name: Archive build
uses: actions/upload-artifact@v3
with:
name: build-${{ needs.check_env.outputs.env_name }}
path: services/inspection-report/build
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v2
# # Setup gcloud CLI
# - name: "auth google"
# uses: "google-github-actions/auth@v0"
# with:
# credentials_json: "${{ secrets.GKE_SA_KEY }}"
# - name: 'Set up Cloud SDK'
# uses: 'google-github-actions/setup-gcloud@v0'
# - name: "configure docker"
# run: |
# gcloud auth configure-docker europe-docker.pkg.dev --quiet
# - name: Build and push
# uses: docker/build-push-action@v3
# with:
# push: true
# context: services/inspection-report/
# tags: europe-west1-docker.pkg.dev/monk-dev-303707/monk-apps-dev/front-cna:latest-${{ needs.check_env.outputs.env_name }}
deploy:
container:
image: dtzar/helm-kubectl:3.6.3
environment: ${{ needs.check_env.outputs.env_name }}
runs-on: ubuntu-latest
needs:
- check_env
- build
steps:
# Setup gcloud CLI
- name: "auth"
uses: "google-github-actions/auth@v0"
with:
credentials_json: "${{ secrets.GKE_SA_KEY }}"
# Get the GKE credentials so we can deploy to the cluster
- uses: google-github-actions/[email protected]
with:
cluster_name: ${{ secrets.GKE_CLUSTER }}
location: ${{ secrets.GKE_ZONE }}
project_id: ${{ secrets.GKE_PROJECT }}
- name: Download the build artifact
uses: actions/download-artifact@v2
with:
name: build-${{ needs.check_env.outputs.env_name }}
path: inspection-report-${{ needs.check_env.outputs.env_name }}
# Deploy to the GKE cluster
- name: Deploy
run: |-
kubectl -n poc cp inspection-report-${{ needs.check_env.outputs.env_name }} poc/$(kubectl get pods -n poc -l app.kubernetes.io/instance=poc-spa --no-headers | grep Running | awk '{print $1}'):/app/