Skip to content

Commit

Permalink
Deploy Client through ci/cd.
Browse files Browse the repository at this point in the history
  • Loading branch information
anybodys committed Feb 18, 2024
1 parent ad79bff commit 8f021ac
Show file tree
Hide file tree
Showing 8 changed files with 15,696 additions and 10,294 deletions.
79 changes: 79 additions & 0 deletions .github/workflows/client.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Client CI/CD

on:
push:
paths:
- 'client/**'
- '.github/workflows/client.yaml*'

defaults:
run:
working-directory: client

env:
GOOGLE_CREDENTIALS: ${{ secrets.GCP_CD }}
REGION: 'us-west2'
PROJECT: "artist-2d"
SERVICE_NAME: "artist-2d-client"

jobs:
build:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'

strategy:
matrix:
node-version: [20.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build --if-present
env:
NODE_OPTIONS: "--openssl-legacy-provider"
- run: npm test

deploy-gcr:
name: Deploy to GCR
#needs: build
runs-on: ubuntu-latest
#if: github.ref == 'refs/heads/main'

env:
IMAGE_TAG: "gcr.io/{$PROJECT}/client:${GITHUB_SHA}"

steps:
- name: Checkout Repo
uses: actions/checkout@main

- run: echo "${IMAGE_TAG}"
- run: echo "${{ env.IMAGE_TAG }}"
- run: echo "${GITHUB_SHA}"

- uses: 'actions/checkout@v4'
- name: Setup GCloud Auth
id: auth
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_CD }}

- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2

# Build and push image to Google Container Registry
- name: Build & Push
run: gcloud builds submit --tag ${IMAGE_TAG}

# Deploy image to Cloud Run
- name: Deploy GCR
run: |-
gcloud run deploy "$SERVICE_NAME" \
--quiet \
--region "${REGION}" \
--image "${{ env.IMAGE_TAG }}" \
--platform "managed" \
--allow-unauthenticated
3 changes: 3 additions & 0 deletions .github/workflows/infra.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: Terraform CD

on:
push:
paths:
- 'infra/**'
- '.github/workflows/infra.yaml'

env:
GOOGLE_CREDENTIALS: ${{ secrets.GCP_CD }}
Expand Down
6 changes: 6 additions & 0 deletions client/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules
build
.dockerignore
Dockerfile
Dockerfile.prod
.gcloudignore
20 changes: 20 additions & 0 deletions client/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# pull official base image
FROM node:20.11-slim

# set working directory
WORKDIR /app

# add `/app/node_modules/.bin` to $PATH
ENV PATH /app/node_modules/.bin:$PATH

# install app dependencies
COPY package.json ./
COPY package-lock.json ./
RUN npm install --silent
RUN npm install [email protected] -g --silent

# add app
COPY . ./

# start app
CMD ["npm", "start"]
Loading

0 comments on commit 8f021ac

Please sign in to comment.