Skip to content

Commit 797133b

Browse files
authored
Merge pull request #30 from untacorp/roadto-stable-release
Workflow and GHCR
2 parents 173b4a3 + 4b8e70e commit 797133b

14 files changed

Lines changed: 335 additions & 27 deletions

File tree

.dockerignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,8 @@ frontend/build/
88
.git/
99
.agents/
1010
.vscode/
11+
**/.env
12+
**/.env.docker
13+
**/.env.prod
14+
**/.env.*
15+
!**/.env.example
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Build and Release Docker Images
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*' # Memicu alur kerja setiap kali melakukan push tag seperti v1.0.0, v2.1.3, dll.
7+
8+
jobs:
9+
build-and-push:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
packages: write
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
- name: Set up Docker Buildx
20+
uses: docker/setup-buildx-action@v3
21+
22+
# Login ke GitHub Container Registry menggunakan token otomatis bawaan GitHub
23+
- name: Log in to GitHub Container Registry
24+
uses: docker/login-action@v3
25+
with:
26+
registry: ghcr.io
27+
username: ${{ github.actor }}
28+
password: ${{ secrets.GITHUB_TOKEN }}
29+
30+
# ─── BUILD & PUSH BACKEND ──────────────────────────────────────────────────
31+
- name: Extract Backend Metadata
32+
id: meta-backend
33+
uses: docker/metadata-action@v5
34+
with:
35+
images: ghcr.io/${{ github.repository }}-backend
36+
tags: |
37+
type=semver,pattern={{version}}
38+
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v') }}
39+
40+
- name: Build and Push Backend Image
41+
uses: docker/build-push-action@v5
42+
with:
43+
context: ./backend
44+
push: true
45+
tags: ${{ id.meta-backend.outputs.tags }}
46+
labels: ${{ id.meta-backend.outputs.labels }}
47+
cache-from: type=gha
48+
cache-to: type=gha,mode=max
49+
50+
# ─── BUILD & PUSH FRONTEND ─────────────────────────────────────────────────
51+
- name: Extract Frontend Metadata
52+
id: meta-frontend
53+
uses: docker/metadata-action@v5
54+
with:
55+
images: ghcr.io/${{ github.repository }}-frontend
56+
tags: |
57+
type=semver,pattern={{version}}
58+
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v') }}
59+
60+
- name: Build and Push Frontend Image
61+
uses: docker/build-push-action@v5
62+
with:
63+
context: ./frontend
64+
push: true
65+
tags: ${{ id.meta-frontend.outputs.tags }}
66+
labels: ${{ id.meta-frontend.outputs.labels }}
67+
cache-from: type=gha
68+
cache-to: type=gha,mode=max

.github/workflows/eslint.yml

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,30 @@ jobs:
3030
- name: Checkout code
3131
uses: actions/checkout@v4
3232

33-
- name: Install ESLint
34-
run: |
35-
npm install eslint@8.10.0
36-
npm install @microsoft/eslint-formatter-sarif@3.1.0
33+
- name: Setup pnpm
34+
uses: pnpm/action-setup@v3
35+
with:
36+
version: 11
37+
38+
- name: Setup Node.js
39+
uses: actions/setup-node@v4
40+
with:
41+
node-version: 20
42+
cache: pnpm
43+
cache-dependency-path: backend/pnpm-lock.yaml
44+
45+
- name: Install dependencies
46+
run: pnpm install --frozen-lockfile
47+
working-directory: backend
3748

3849
- name: Run ESLint
3950
env:
4051
SARIF_ESLINT_IGNORE_SUPPRESSED: "true"
41-
# fix: Menambahkan backslash (\) untuk menyambung perintah ke baris berikutnya
42-
run: npx eslint . \
43-
--config .eslintrc.js \
44-
--ext .js,.jsx,.ts,.tsx \
45-
--format @microsoft/eslint-formatter-sarif \
46-
--output-file eslint-results.sarif
52+
run: pnpm exec eslint "{src,apps,libs,test}/**/*.ts" --format @microsoft/eslint-formatter-sarif --output-file ../eslint-results.sarif
53+
working-directory: backend
4754
continue-on-error: true
4855

4956
- name: Upload analysis results to GitHub
50-
# fix: Mengubah versi v3 menjadi v4 sesuai instruksi peringatan
5157
uses: github/codeql-action/upload-sarif@v4
5258
with:
5359
sarif_file: eslint-results.sarif

backend/.dockerignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules
2+
dist
3+
.env
4+
.env.docker
5+
.env.prod
6+
.env.*
7+
!.env.example

backend/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
"@nestjs/schedule": "^6.1.3",
3737
"@nestjs/websockets": "^11.1.19",
3838
"@prisma/client": "^6.19.3",
39-
"prisma": "^6.19.3",
4039
"bcrypt": "^6.0.0",
4140
"bull": "^4.16.5",
4241
"cassandra-driver": "^4.9.0",
@@ -47,6 +46,7 @@
4746
"minio": "^8.0.7",
4847
"passport": "^0.7.0",
4948
"passport-jwt": "^4.0.1",
49+
"prisma": "^6.19.3",
5050
"reflect-metadata": "^0.2.2",
5151
"rxjs": "^7.8.1",
5252
"socket.io": "^4.8.3",
@@ -55,6 +55,7 @@
5555
"devDependencies": {
5656
"@eslint/eslintrc": "^3.2.0",
5757
"@eslint/js": "^9.18.0",
58+
"@microsoft/eslint-formatter-sarif": "^3.1.0",
5859
"@nestjs/cli": "^11.0.0",
5960
"@nestjs/schematics": "^11.0.0",
6061
"@nestjs/testing": "^11.0.1",

0 commit comments

Comments
 (0)