Skip to content

Commit

Permalink
cicd: updated github deploy action
Browse files Browse the repository at this point in the history
  • Loading branch information
froid1911 committed Jan 30, 2024
1 parent 779f395 commit 0cda777
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 108 deletions.
118 changes: 12 additions & 106 deletions .github/workflows/build-and-deploy-staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,115 +2,21 @@ name: Deploy Switchboard Staging

on:
push:
branches: [ main ]
branches: [feat/documentDrive, main]
jobs:
build:
name: build and push to ghcr
runs-on: ubuntu-latest
permissions: write-all

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to GitHub Packages
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ secrets.GH_SIDSTRM_BUILD_AND_DEPLOY_USER }}
password: ${{ secrets.GH_SIDSTRM_BUILD_AND_DEPLOY_TOKEN }}

- name: Set outputs
id: vars
run: echo "git_hash_short=$(git rev-parse --short ${GITHUB_SHA})" >> $GITHUB_OUTPUT

- name: Build and Push switchboard-api
uses: docker/build-push-action@v3
with:
context: ./api
platforms: linux/amd64
push: true
tags: |
ghcr.io/sidestream-tech/switchboard/api:main
ghcr.io/sidestream-tech/switchboard/api:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Build and Push switchboard-wundergraph
uses: docker/build-push-action@v3
with:
context: ./wundergraph
platforms: linux/amd64
push: true
tags: |
ghcr.io/sidestream-tech/switchboard/wundergraph:main
ghcr.io/sidestream-tech/switchboard/wundergraph:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Build and Push switchboard-frontend
uses: docker/build-push-action@v3
with:
context: .
file: ./frontend/Dockerfile
platforms: linux/amd64
push: true
tags: |
ghcr.io/sidestream-tech/switchboard/frontend:main
ghcr.io/sidestream-tech/switchboard/frontend:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max

deploy:
name: deploy staging to sidestream cluster
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout k8s-projects Repo
uses: actions/checkout@v3
with:
repository: sidestream-tech/k8s-projects
token: ${{ secrets.GH_SIDSTRM_BUILD_AND_DEPLOY_TOKEN }}
path: k8s-projects
ref: main

- uses: benjlevesque/[email protected]
id: short-sha
with:
length: 6

- name: Update Value File API
uses: mikefarah/yq@master
with:
cmd: yq -i '(.image.tag ="${{ github.sha }}") | (.commitShortSHA ="${{ github.sha }}") | (.releaseTag ="${{ github.ref_name }}")' $VALUES_FILE
env:
VALUES_FILE: "k8s-projects/switchboard-api/staging/values-api.yml"

- name: Update Value File Wundergraph
uses: mikefarah/yq@master
with:
cmd: yq -i '(.image.tag ="${{ github.sha }}") | (.commitShortSHA ="${{ github.sha }}") | (.releaseTag ="${{ github.ref_name }}")' $VALUES_FILE
env:
VALUES_FILE: "k8s-projects/switchboard-api/staging/values-wundergraph.yml"

- name: Update Value File Frontend
uses: mikefarah/yq@master
with:
cmd: yq -i '(.image.tag ="${{ github.sha }}") | (.commitShortSHA ="${{ github.sha }}") | (.releaseTag ="${{ github.ref_name }}")' $VALUES_FILE
env:
VALUES_FILE: "k8s-projects/switchboard-api/staging/values-frontend.yml"
# Check-out your repository.
- name: Checkout
uses: actions/checkout@v2

- name: Commit & Push changes
uses: actions-js/push@master
- name: Build, Push and Release API to Heroku. # Your custom step name
uses: gonuit/[email protected]
with:
github_token: ${{ secrets.GH_SIDSTRM_BUILD_AND_DEPLOY_TOKEN }}
repository: sidestream-tech/k8s-projects
branch: main
message: "[ArgoCD]: ${{ github.workflow }} to `${{ steps.short-sha.outputs.sha }}` :rocket:"
directory: k8s-projects
email: ${{ secrets.HEROKU_EMAIL }}
heroku_api_key: ${{ secrets.HEROKU_API_KEY }}
heroku_app_name: ${{ secrets.HEROKU_APP_NAME }}
dockerfile_directory: ./api
dockerfile_name: Dockerfile
process_type: web
2 changes: 1 addition & 1 deletion api/Dockerfile.api → api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
ARG NODE_VERSION=node:16.14.2

FROM $NODE_VERSION AS dependency-base
ENV PORT=3000
ENV PORT=$PORT
ENV DATABASE_URL=$DATABASE_URL
ENV JWT_SECRET=$JWT_SECRET
ENV AUTH_SIGNUP_ENABLED=$AUTH_SIGNUP_ENABLED
Expand Down
2 changes: 1 addition & 1 deletion api/src/env/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getJwtSecret, getJwtExpirationPeriod } from "./getters";
dotenv.config();

export const JWT_SECRET = getJwtSecret();
export const PORT = 3000;
export const PORT = process.env.PORT ?? "3000";
export const isDevelopment = process.env.NODE_ENV === "development";
export const AUTH_SIGNUP_ENABLED = Boolean(process.env.AUTH_SIGNUP_ENABLED);
export const JWT_EXPIRATION_PERIOD: string = getJwtExpirationPeriod();
Expand Down

0 comments on commit 0cda777

Please sign in to comment.