Skip to content

Commit b39341a

Browse files
committed
16th commit
1 parent 2617a4e commit b39341a

2 files changed

Lines changed: 271 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: CI Pipeline
2+
3+
on:
4+
push:
5+
branches: [docker]
6+
pull_request:
7+
branches: [docker]
8+
9+
jobs:
10+
test-and-build:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
node-version: [22.x]
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Setup Node.js ${{ matrix.node-version }}
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: ${{ matrix.node-version }}
25+
cache: "npm"
26+
27+
- name: Install dependencies
28+
run: npm ci
29+
30+
- name: Run ESLint
31+
run: npm run lint
32+
33+
- name: TypeScript type check
34+
run: npx tsc --noEmit
35+
36+
- name: Security audit
37+
run: npm audit --audit-level=high
38+
continue-on-error: true
39+
40+
- name: Build project
41+
run: npm run build
42+
env:
43+
VITE_GEMINI_API_KEY: ${{ secrets.VITE_GEMINI_API_KEY }}
44+
45+
- name: Upload build artifacts
46+
uses: actions/upload-artifact@v4
47+
with:
48+
name: build-files
49+
path: dist/
50+
retention-days: 7
51+
52+
docker-build:
53+
needs: test-and-build
54+
runs-on: ubuntu-latest
55+
if: github.ref == 'refs/heads/docker'
56+
57+
steps:
58+
- name: Checkout code
59+
uses: actions/checkout@v4
60+
61+
- name: Set up Docker Buildx
62+
uses: docker/setup-buildx-action@v3
63+
64+
- name: Login to Docker Hub
65+
uses: docker/login-action@v3
66+
with:
67+
username: ${{ secrets.DOCKER_USERNAME }}
68+
password: ${{ secrets.DOCKER_PASSWORD }}
69+
70+
- name: Extract metadata
71+
id: meta
72+
uses: docker/metadata-action@v5
73+
with:
74+
images: ${{ secrets.DOCKER_USERNAME }}/vrt-games-website
75+
tags: |
76+
type=ref,event=branch
77+
type=ref,event=pr
78+
type=sha,prefix=main-,suffix=-{{date 'YYYYMMDD'}},enable={{is_default_branch}}
79+
type=raw,value=latest,enable={{is_default_branch}}
80+
81+
- name: Build and push Docker image
82+
uses: docker/build-push-action@v5
83+
with:
84+
context: .
85+
push: true
86+
tags: ${{ steps.meta.outputs.tags }}
87+
labels: ${{ steps.meta.outputs.labels }}
88+
build-args: |
89+
VITE_GEMINI_API_KEY=${{ secrets.VITE_GEMINI_API_KEY }}
90+
cache-from: type=gha
91+
cache-to: type=gha,mode=max

.github/workflows/deploy.yml

Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
name: Deploy to Production
2+
3+
on:
4+
push:
5+
branches: [docker]
6+
workflow_dispatch:
7+
inputs:
8+
environment:
9+
description: "Deployment environment"
10+
required: true
11+
default: "production"
12+
type: choice
13+
options:
14+
- production
15+
- staging
16+
17+
env:
18+
REGISTRY: ghcr.io
19+
IMAGE_NAME: ${{ github.repository }}
20+
21+
jobs:
22+
deploy-staging:
23+
if: github.ref == 'refs/heads/docker' && (github.event.inputs.environment == 'staging' || github.event_name == 'push')
24+
runs-on: ubuntu-latest
25+
environment: staging
26+
27+
steps:
28+
- name: Checkout code
29+
uses: actions/checkout@v4
30+
31+
- name: Setup Node.js
32+
uses: actions/setup-node@v4
33+
with:
34+
node-version: "22.x"
35+
cache: "npm"
36+
37+
- name: Install dependencies
38+
run: npm ci
39+
40+
- name: Build for staging
41+
run: npm run build
42+
env:
43+
VITE_GEMINI_API_KEY: ${{ secrets.VITE_GEMINI_API_KEY_STAGING }}
44+
NODE_ENV: staging
45+
46+
- name: Deploy to Vercel (Staging)
47+
uses: amondnet/vercel-action@v25
48+
with:
49+
vercel-token: ${{ secrets.VERCEL_TOKEN }}
50+
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
51+
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }}
52+
working-directory: ./
53+
scope: ${{ secrets.VERCEL_ORG_ID }}
54+
55+
- name: Comment PR with preview URL
56+
if: github.event_name == 'pull_request'
57+
uses: actions/github-script@v7
58+
with:
59+
script: |
60+
github.rest.issues.createComment({
61+
issue_number: context.issue.number,
62+
owner: context.repo.owner,
63+
repo: context.repo.repo,
64+
body: '🚀 Deployed to staging! Preview: https://vrt-games-staging.vercel.app'
65+
})
66+
67+
deploy-production:
68+
if: github.ref == 'refs/heads/docker' && (github.event.inputs.environment == 'production' || github.event_name == 'push')
69+
runs-on: ubuntu-latest
70+
environment: production
71+
needs: [deploy-staging]
72+
73+
steps:
74+
- name: Checkout code
75+
uses: actions/checkout@v4
76+
77+
- name: Setup Node.js
78+
uses: actions/setup-node@v4
79+
with:
80+
node-version: "22.x"
81+
cache: "npm"
82+
83+
- name: Install dependencies
84+
run: npm ci
85+
86+
- name: Build for production
87+
run: npm run build
88+
env:
89+
VITE_GEMINI_API_KEY: ${{ secrets.VITE_GEMINI_API_KEY_PRODUCTION }}
90+
NODE_ENV: production
91+
92+
- name: Deploy to Vercel (Production)
93+
uses: amondnet/vercel-action@v25
94+
with:
95+
vercel-token: ${{ secrets.VERCEL_TOKEN }}
96+
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
97+
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }}
98+
vercel-args: "--prod"
99+
working-directory: ./
100+
scope: ${{ secrets.VERCEL_ORG_ID }}
101+
102+
- name: Create GitHub Release
103+
if: github.event_name == 'push'
104+
uses: actions/create-release@v1
105+
env:
106+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
107+
with:
108+
tag_name: v${{ github.run_number }}
109+
release_name: Release v${{ github.run_number }}
110+
body: |
111+
🎮 VRT Games Website - Production Release
112+
113+
**Changes in this release:**
114+
- ${{ github.event.head_commit.message }}
115+
116+
**Deployed to:** https://vrt-games.vercel.app
117+
**Commit:** ${{ github.sha }}
118+
draft: false
119+
prerelease: false
120+
121+
docker-deploy:
122+
if: github.ref == 'refs/heads/docker'
123+
runs-on: ubuntu-latest
124+
environment: production
125+
126+
steps:
127+
- name: Checkout code
128+
uses: actions/checkout@v4
129+
130+
- name: Set up Docker Buildx
131+
uses: docker/setup-buildx-action@v3
132+
133+
- name: Login to GitHub Container Registry
134+
uses: docker/login-action@v3
135+
with:
136+
registry: ${{ env.REGISTRY }}
137+
username: ${{ github.actor }}
138+
password: ${{ secrets.GITHUB_TOKEN }}
139+
140+
- name: Extract metadata
141+
id: meta
142+
uses: docker/metadata-action@v5
143+
with:
144+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
145+
tags: |
146+
type=ref,event=branch
147+
type=sha,prefix=prod-,suffix=-{{date 'YYYYMMDD'}}
148+
type=raw,value=latest
149+
150+
- name: Build and push production Docker image
151+
uses: docker/build-push-action@v5
152+
with:
153+
context: .
154+
push: true
155+
tags: ${{ steps.meta.outputs.tags }}
156+
labels: ${{ steps.meta.outputs.labels }}
157+
build-args: |
158+
VITE_GEMINI_API_KEY=${{ secrets.VITE_GEMINI_API_KEY_PRODUCTION }}
159+
cache-from: type=gha
160+
cache-to: type=gha,mode=max
161+
162+
notify-deployment:
163+
runs-on: ubuntu-latest
164+
needs: [deploy-production, docker-deploy]
165+
if: always()
166+
167+
steps:
168+
- name: Notify deployment status
169+
uses: 8398a7/action-slack@v3
170+
if: always()
171+
with:
172+
status: ${{ job.status }}
173+
channel: "#deployments"
174+
webhook_url: ${{ secrets.SLACK_WEBHOOK }}
175+
text: |
176+
🎮 VRT Games Website deployment completed!
177+
Status: ${{ job.status }}
178+
Environment: Production
179+
Commit: ${{ github.sha }}
180+
Author: ${{ github.actor }}

0 commit comments

Comments
 (0)