Skip to content

Commit

Permalink
chore(ci): CI rework
Browse files Browse the repository at this point in the history
  • Loading branch information
rajdip-b committed Feb 12, 2024
1 parent 7bb3d21 commit 788c141
Show file tree
Hide file tree
Showing 8 changed files with 155 additions and 141 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/release-api.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
on:
push:
branches:
- main
tags:
- '*'

jobs:
build-api-release:
runs-on: ubuntu-latest
name: Build and push API docker image for release
if: ${{ startsWith(github.ref , 'refs/tags/')}}

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

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build Docker image
run: docker build -t keyshade/keyshade-api:${{ github.ref_name }} keyshade/keyshade-api:latest -f ./apps/api/Dockerfile .

- name: Push Docker image
run: docker push keyshade/keyshade-api
28 changes: 28 additions & 0 deletions .github/workflows/release-web.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
on:
push:
branches:
- main
tags:
- '*'

jobs:
build-web-release:
runs-on: ubuntu-latest
name: Build and push Web docker image for release
if: ${{ startsWith(github.ref , 'refs/tags/') }}

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

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build Docker image
run: docker build -t keyshade/keyshade-web:${{ github.ref_name }} keyshade/keyshade-web:latest -f ./apps/web/Dockerfile .

- name: Push Docker image
run: docker push keyshade/keyshade-web
20 changes: 20 additions & 0 deletions .github/workflows/stage-api.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
on:
push:
branches:
- develop
paths: ['apps/api/**', '.github/workflows/api.yaml']

jobs:
deploy-api-stage:
runs-on: ubuntu-latest
name: Deploy to stage
if: github.ref == 'refs/heads/develop'

steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install fly CLI
run: |
curl -L https://fly.io/install.sh | sh
- name: Deploy to stage
run: ~/.fly/bin/fly deploy --config fly.api.toml --dockerfile ./apps/api/Dockerfile --app keyshade-api-stage --access-token ${{ secrets.FLY_ACCESS_TOKEN }}
20 changes: 20 additions & 0 deletions .github/workflows/stage-web.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
on:
push:
branches:
- develop
paths: ['apps/web/**', '.github/workflows/web.yaml']

jobs:
deploy-stage:
runs-on: ubuntu-latest
name: Deploy to stage
if: github.ref == 'refs/heads/develop'

steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install fly CLI
run: |
curl -L https://fly.io/install.sh | sh
- name: Deploy to stage
run: ~/.fly/bin/fly deploy --config fly.web.toml --dockerfile ./apps/web/Dockerfile --app keyshade-web --access-token ${{ secrets.FLY_ACCESS_TOKEN }}
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
on:
push:
branches:
- develop
paths: ['apps/api/**', '.github/workflows/api.yaml']
tags:
- '*'
pull_request:
paths: ['apps/api/**', '.github/workflows/api.yaml']

jobs:
validate:
runs-on: ubuntu-latest
name: Validate
name: Validate API

steps:
- name: Checkout
Expand Down Expand Up @@ -68,40 +64,3 @@ jobs:
with:
flags: api-e2e-tests
files: /coverage-e2e/api/coverage-final.json

deploy-stage:
runs-on: ubuntu-latest
name: Deploy to stage
if: github.ref == 'refs/heads/develop'
needs: validate

steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install fly CLI
run: |
curl -L https://fly.io/install.sh | sh
- name: Deploy to stage
run: ~/.fly/bin/fly deploy --config fly.api.toml --dockerfile ./apps/api/Dockerfile --app keyshade-api-stage --access-token ${{ secrets.FLY_ACCESS_TOKEN }}

build-api-release:
needs: validate
runs-on: ubuntu-latest
name: Build and push API docker image for release
if: ${{ startsWith(github.ref , 'refs/tags/')}}

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

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build Docker image
run: docker build -t keyshade/keyshade-api:${{ github.ref_name }} keyshade/keyshade-api:latest -f ./apps/api/Dockerfile .

- name: Push Docker image
run: docker push keyshade/keyshade-api
57 changes: 57 additions & 0 deletions .github/workflows/validate-web.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
on:
push:
paths: ['apps/web/**', '.github/workflows/web.yaml']
pull_request:
paths: ['apps/web/**', '.github/workflows/web.yaml']

jobs:
validate:
runs-on: ubuntu-latest
name: Validate Web

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

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 20

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install packages
run: |
pnpm i
- name: Lint
run: |
pnpm run lint:web
- name: Test
run: |
pnpm run test:web
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
flags: web
98 changes: 0 additions & 98 deletions .github/workflows/web.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

pnpm run lint:fix && pnpm run prettier:fix && pnpm run test:api && pnpm run e2e:api
pnpm run lint:fix && pnpm run prettier:fix

0 comments on commit 788c141

Please sign in to comment.