Skip to content

Merge pull request #11 from zopdev/FIX-BASE-URL-CONFIG #12

Merge pull request #11 from zopdev/FIX-BASE-URL-CONFIG

Merge pull request #11 from zopdev/FIX-BASE-URL-CONFIG #12

name: Build and Deploy for JS(npm) service
on:
push:
branches: [development]
env:
APP_NAME: ui-components
NAMESPACE: kops-dev-stg
CLUSTER_NAME: raramuri-tech
CLUSTER_PROJECT: raramuri-tech
GAR_PROJECT: raramuri-tech
GAR_REGISTRY: kops-dev
jobs:
dockerize:
runs-on: ubuntu-latest
name: 🐳 Dockerize
outputs:
image: ${{ steps.output-image.outputs.image }}
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: "18.x"
- name: Install dependencies
run: |
echo "@zopsmart:registry=https://npm.pkg.github.com/" >> ~/.npmrc
echo "//npm.pkg.github.com/:_authToken=${{ secrets.PAT }}" >> ~/.npmrc
npm install --legacy-peer-deps
# - name: run linter
# run: |
# CI=false npm run lint
# - name: run prettier
# run: |
# CI=false npm run prettier:check
# - name: run tests
# run: |
# CI=false npm run test:coverage
- name: Build
run: npm run build
- name: Login to GAR
uses: docker/login-action@v2
with:
registry: us-central1-docker.pkg.dev
username: _json_key
password: ${{ secrets.STAGE_DEPLOY_KEY }}
- name: Build and Push Docker Image to GAR
uses: docker/build-push-action@v2
with:
push: true
context: .
file: ./Dockerfile
tags:
us-central1-docker.pkg.dev/${{ env.GAR_PROJECT }}/${{ env.GAR_REGISTRY }}/${{
env.APP_NAME }}:${{ github.sha }}
- id: output-image
run:
echo "image=`echo us-central1-docker.pkg.dev/${{ env.GAR_PROJECT }}/${{ env.GAR_REGISTRY
}}/${{ env.APP_NAME }}:${{ github.sha }}`" >> "$GITHUB_OUTPUT"
deployment:
runs-on: ubuntu-latest
needs: dockerize
name: 🚀 Deploy
container:
image: ghcr.io/zopsmart/gha-images:deployments-0.1.3
options: --rm
env:
image: ${{ needs.dockerize.outputs.image }}
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Authorize to GCP service account
uses: google-github-actions/auth@v1
with:
credentials_json: ${{ secrets.STAGE_DEPLOY_KEY }}
- name: Set GCloud Project and Fetch Cluster Credentials
run:
gcloud container clusters get-credentials ${{ env.CLUSTER_NAME }} --region=us-central1
--project=${{ env.CLUSTER_PROJECT }}
- name: Update Deployment Image using Kubectl
run:
kubectl set image deployment/${{ env.APP_NAME }} ${{ env.APP_NAME }}=${{ env.image }}
--namespace ${{ env.NAMESPACE }}