Skip to content

inspection-report

inspection-report #855

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/