-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
163 additions
and
229 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,8 @@ tests | |
deploy | ||
build.sh | ||
CHANGELOG.md | ||
.github | ||
deploy | ||
.husky | ||
.vscode | ||
volumes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
name: Docker Build | ||
|
||
on: | ||
push: | ||
|
||
jobs: | ||
generate-matrix: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
matrix: ${{ steps.set-matrix.outputs.matrix }} | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Generate Matrix | ||
id: set-matrix | ||
run: | | ||
apps=$(ls -d apps/*/) | ||
matrix="{\"include\":[" | ||
for app in $apps; do | ||
app_name=$(basename $app) | ||
matrix="${matrix}{\"app-dir\":\"${app_name}\",\"app-package-name\":\"@npcs/${app_name}\",\"image-name\":\"ghcr.io/${{ github.actor }}/npcs-${app_name}:latest\"}," | ||
done | ||
matrix="${matrix%?}]}" | ||
echo "::set-output name=matrix::${matrix}" | ||
build: | ||
needs: generate-matrix | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }} | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Login Registry | ||
if: github.ref == 'refs/heads/main' | ||
run: | | ||
echo ${{ secrets.PAT }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin | ||
- name: Build Docker Image | ||
id: docker_build | ||
uses: docker/build-push-action@v6 | ||
with: | ||
push: ${{ github.ref == 'refs/heads/main' && 'true' || 'false' }} | ||
tags: ${{ matrix.image-name }} | ||
cache-from: type=registry,ref=${{ matrix.image-name }} | ||
cache-to: type=inline | ||
context: . | ||
file: ${{ secrets.DOCKERFILE }} | ||
build-args: | | ||
TURBO_TEAM=${{ secrets.TURBO_TEAM }} | ||
TURBO_TOKEN=${{ secrets.TURBO_TOKEN }} | ||
APP_DIR=apps/${{ matrix.app-dir }} | ||
APP_PACKAGE_NAME=${{ matrix.app-package-name }} | ||
- run: | | ||
echo "Docker Image ID: ${{ steps.docker_build.outputs.imageid }}" | ||
echo "Docker Image digest: ${{ steps.docker_build.outputs.digest }}" | ||
echo "Docker Image metadata: ${{ steps.docker_build.outputs.metadata }}" | ||
- name: Trigger Deploy | ||
if: github.ref == 'refs/heads/main' | ||
run: | | ||
curl -X POST \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "Authorization: Bearer ${{ secrets.PAT }}" \ | ||
-d "{\"event_type\":\"deploy\",\"client_payload\":{\"app\":\"${{ matrix.app-dir }}\"}}" \ | ||
https://api.github.com/repos/${{ github.repository }}/dispatches | ||
- name: Check Deploy Event | ||
run: | | ||
echo "Deploy event triggered for app: ${{ matrix.app-dir }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: Docker Deploy | ||
|
||
on: | ||
repository_dispatch: | ||
types: [deploy] | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Upload to VPS | ||
uses: appleboy/scp-action@master | ||
with: | ||
host: ${{ secrets.VPS_HOST }} | ||
username: ${{ secrets.VPS_USER }} | ||
key: ${{ secrets.VPS_SSH_KEY }} | ||
port: ${{ secrets.VPS_PORT }} | ||
source: ./deploy | ||
target: ${{ secrets.VPS_WORK_DIR }} | ||
|
||
- name: Execute deployment via SSH | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.VPS_HOST }} | ||
username: ${{ secrets.VPS_USER }} | ||
key: ${{ secrets.VPS_SSH_KEY }} | ||
port: ${{ secrets.VPS_PORT }} | ||
envs: REPO_NAME | ||
script: | | ||
cd ${{ secrets.VPS_WORK_DIR }}/deploy | ||
export $(grep -v '^#' ~/.env.local | xargs) | ||
docker compose pull ${{ github.event.client_payload.app }} | ||
docker compose up -d ${{ github.event.client_payload.app }} | ||
docker image prune -f |
10 changes: 5 additions & 5 deletions
10
.github/workflows/monorepo-integrity.yml → .github/workflows/integrity.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Quality | ||
|
||
on: | ||
push: | ||
|
||
env: | ||
TURBO_TEAM: ${{ secrets.TURBO_TEAM }} | ||
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} | ||
|
||
jobs: | ||
check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: 📥 Install dependencies | ||
uses: ./.github/actions/setup | ||
|
||
- name: Run check tasks with Turbo | ||
run: | | ||
# To fix the file or directory not find error emmittied by prisma | ||
pnpm turbo prisma-generate --concurrency 1 | ||
pnpm turbo typecheck | ||
pnpm turbo lint test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.