Skip to content

Commit b312fdc

Browse files
authored
Update registration is not disabled when KV store says its disabled bug (#18)
* Update navbar * yeee * ok * update (thx coderabiit) * ok * Important Patch * Fix NEW React DoS & Source Code leak vulns * super basic imageViewer * Update SQL & Add system_info route. * Update registartion not disabled bug * Update Version
1 parent a396c57 commit b312fdc

File tree

11 files changed

+1098
-81
lines changed

11 files changed

+1098
-81
lines changed
Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
name: Production Release
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- main
8+
workflow_dispatch:
9+
10+
env:
11+
REGISTRY: ghcr.io
12+
IMAGE_NAME: ${{ github.repository }}
13+
14+
jobs:
15+
production-release:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: write
19+
packages: write
20+
# Skip if the commit message contains the auto-increment marker to prevent infinite loops
21+
if: "!contains(github.event.head_commit.message, '🤖 Auto-increment version')"
22+
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v4
26+
with:
27+
token: ${{ secrets.GITHUB_TOKEN }}
28+
fetch-depth: 0
29+
30+
- name: Setup Node.js
31+
uses: actions/setup-node@v4
32+
with:
33+
node-version: "20"
34+
35+
- name: Update versions using comprehensive management script
36+
id: version_update
37+
run: |
38+
# Make script executable
39+
chmod +x .github/scripts/manage-versions.js
40+
41+
# Run the comprehensive version management script
42+
node .github/scripts/manage-versions.js
43+
44+
# Display updated files
45+
echo "Updated projectData.ts:"
46+
cat apps/web/projectData.ts
47+
echo ""
48+
echo "Updated version.json:"
49+
cat version.json
50+
51+
- name: Check for changes
52+
id: git_status
53+
run: |
54+
if [ -n "$(git status --porcelain)" ]; then
55+
echo "changes=true" >> $GITHUB_OUTPUT
56+
else
57+
echo "changes=false" >> $GITHUB_OUTPUT
58+
fi
59+
60+
- name: Commit version changes
61+
if: steps.git_status.outputs.changes == 'true'
62+
run: |
63+
git config --local user.email "action@github.com"
64+
git config --local user.name "GitHub Action"
65+
66+
# Add all changed files
67+
git add apps/web/projectData.ts version.json
68+
69+
# Add version file if it was created
70+
if [ -n "${{ steps.version_update.outputs.version_file }}" ]; then
71+
git add "Versions/${{ steps.version_update.outputs.version_file }}"
72+
fi
73+
74+
git commit -m "🤖 Auto-increment version to ${{ steps.version_update.outputs.new_version }} (prod: ${{ steps.version_update.outputs.prod_version }}, dev: ${{ steps.version_update.outputs.dev_version }})"
75+
git push
76+
77+
- name: Log in to the Container registry
78+
uses: docker/login-action@v3
79+
with:
80+
registry: ${{ env.REGISTRY }}
81+
username: ${{ github.actor }}
82+
password: ${{ secrets.GITHUB_TOKEN }}
83+
84+
- name: Extract metadata (tags, labels) for Docker
85+
id: meta
86+
uses: docker/metadata-action@v5
87+
with:
88+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
89+
tags: |
90+
type=raw,value=latest
91+
type=raw,value=${{ steps.version_update.outputs.new_version }}
92+
type=raw,value=${{ steps.version_update.outputs.prod_version }},enable={{isBranch 'master'}}
93+
type=ref,event=branch
94+
type=semver,pattern={{version}}
95+
type=sha,prefix=
96+
97+
- name: Set up Docker Buildx
98+
uses: docker/setup-buildx-action@v3
99+
100+
- name: Build and push Docker image
101+
uses: docker/build-push-action@v5
102+
with:
103+
context: .
104+
push: true
105+
tags: ${{ steps.meta.outputs.tags }}
106+
labels: ${{ steps.meta.outputs.labels }}
107+
cache-from: type=gha
108+
cache-to: type=gha,mode=max
109+
110+
- name: Create version branch (stable releases only)
111+
if: steps.git_status.outputs.changes == 'true' && steps.version_update.outputs.is_stable == 'true' && steps.version_update.outputs.is_master == 'true'
112+
run: |
113+
# Create a new branch for this stable version
114+
git checkout -b "release/v${{ steps.version_update.outputs.new_version }}"
115+
git push origin "release/v${{ steps.version_update.outputs.new_version }}"
116+
117+
# Switch back to main branch
118+
git checkout ${{ github.ref_name }}
119+
120+
- name: Generate release notes (stable releases only)
121+
if: steps.git_status.outputs.changes == 'true' && steps.version_update.outputs.is_stable == 'true' && steps.version_update.outputs.is_master == 'true'
122+
id: release_notes
123+
run: |
124+
# Make script executable
125+
chmod +x .github/scripts/generate-release-notes.js
126+
127+
# Generate release notes using the script
128+
node .github/scripts/generate-release-notes.js "${{ steps.version_update.outputs.new_version }}"
129+
130+
- name: Create Git Tag (stable releases only)
131+
if: steps.git_status.outputs.changes == 'true' && steps.version_update.outputs.is_stable == 'true' && steps.version_update.outputs.is_master == 'true'
132+
run: |
133+
git tag v${{ steps.version_update.outputs.new_version }}
134+
git push origin v${{ steps.version_update.outputs.new_version }}
135+
136+
- name: Create GitHub Release (stable releases only)
137+
if: steps.git_status.outputs.changes == 'true' && steps.version_update.outputs.is_stable == 'true' && steps.version_update.outputs.is_master == 'true'
138+
env:
139+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
140+
run: |
141+
# Use version file if created, otherwise use generated release notes
142+
if [ -f "Versions/${{ steps.version_update.outputs.version_file }}" ]; then
143+
NOTES_FILE="Versions/${{ steps.version_update.outputs.version_file }}"
144+
else
145+
NOTES_FILE="release-notes.md"
146+
fi
147+
148+
# Create release using GitHub CLI
149+
gh release create v${{ steps.version_update.outputs.new_version }} \
150+
--title "Release v${{ steps.version_update.outputs.new_version }}" \
151+
--notes-file "$NOTES_FILE" \
152+
--latest
153+
154+
- name: Output summary
155+
run: |
156+
echo "## 🚀 Production Release Summary" >> $GITHUB_STEP_SUMMARY
157+
echo "- **Previous version:** ${{ steps.version_update.outputs.previous_version }}" >> $GITHUB_STEP_SUMMARY
158+
echo "- **New version:** ${{ steps.version_update.outputs.new_version }}" >> $GITHUB_STEP_SUMMARY
159+
echo "- **Production version:** ${{ steps.version_update.outputs.prod_version }}" >> $GITHUB_STEP_SUMMARY
160+
echo "- **Development version:** ${{ steps.version_update.outputs.dev_version }}" >> $GITHUB_STEP_SUMMARY
161+
echo "- **Branch:** ${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY
162+
echo "- **Stable release:** ${{ steps.version_update.outputs.is_stable }}" >> $GITHUB_STEP_SUMMARY
163+
echo "" >> $GITHUB_STEP_SUMMARY
164+
165+
echo "### 🐳 Docker Images Built" >> $GITHUB_STEP_SUMMARY
166+
echo "- \`${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest\`" >> $GITHUB_STEP_SUMMARY
167+
echo "- \`${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version_update.outputs.new_version }}\`" >> $GITHUB_STEP_SUMMARY
168+
169+
if [ "${{ steps.version_update.outputs.is_master }}" == "true" ]; then
170+
echo "- \`${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version_update.outputs.prod_version }}\`" >> $GITHUB_STEP_SUMMARY
171+
fi
172+
echo "" >> $GITHUB_STEP_SUMMARY
173+
174+
echo "### 📁 Files Updated" >> $GITHUB_STEP_SUMMARY
175+
echo "- \`apps/web/projectData.ts\` - Updated to ${{ steps.version_update.outputs.new_version }}" >> $GITHUB_STEP_SUMMARY
176+
echo "- \`version.json\` - prod: ${{ steps.version_update.outputs.prod_version }}, dev: ${{ steps.version_update.outputs.dev_version }}" >> $GITHUB_STEP_SUMMARY
177+
178+
if [ -n "${{ steps.version_update.outputs.version_file }}" ]; then
179+
echo "- \`Versions/${{ steps.version_update.outputs.version_file }}\` - New version file created" >> $GITHUB_STEP_SUMMARY
180+
fi
181+
echo "" >> $GITHUB_STEP_SUMMARY
182+
183+
if [ "${{ steps.version_update.outputs.is_stable }}" == "true" ] && [ "${{ steps.version_update.outputs.is_master }}" == "true" ]; then
184+
echo "### 🏷️ Release Created" >> $GITHUB_STEP_SUMMARY
185+
echo "- **Tag:** \`v${{ steps.version_update.outputs.new_version }}\`" >> $GITHUB_STEP_SUMMARY
186+
echo "- **Branch:** \`release/v${{ steps.version_update.outputs.new_version }}\`" >> $GITHUB_STEP_SUMMARY
187+
echo "- **Release:** [v${{ steps.version_update.outputs.new_version }}](https://github.com/${{ github.repository }}/releases/tag/v${{ steps.version_update.outputs.new_version }})" >> $GITHUB_STEP_SUMMARY
188+
if [ -n "${{ steps.version_update.outputs.version_file }}" ]; then
189+
echo "- **Version File:** \`Versions/${{ steps.version_update.outputs.version_file }}\`" >> $GITHUB_STEP_SUMMARY
190+
fi
191+
else
192+
echo "### ⚠️ Development Build" >> $GITHUB_STEP_SUMMARY
193+
if [ "${{ steps.version_update.outputs.is_master }}" != "true" ]; then
194+
echo "This is a development branch build. No GitHub release or version branch created." >> $GITHUB_STEP_SUMMARY
195+
else
196+
echo "This is a pre-release version (contains alpha, beta, canary, etc.). No GitHub release or version branch created." >> $GITHUB_STEP_SUMMARY
197+
fi
198+
fi
Lines changed: 42 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
name: Auto Update Version and Build
22

33
on:
4-
push:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
56
branches:
67
- master
78
- main
@@ -17,8 +18,11 @@ jobs:
1718
permissions:
1819
contents: write
1920
packages: write
20-
# Skip if the commit message contains the auto-increment marker to prevent infinite loops
21-
if: "!contains(github.event.head_commit.message, '🤖 Auto-increment version')"
21+
# Only run for collaborators or repository owner
22+
if: |
23+
github.event.pull_request.author_association == 'OWNER' ||
24+
github.event.pull_request.author_association == 'COLLABORATOR' ||
25+
github.event.pull_request.author_association == 'MEMBER'
2226
2327
steps:
2428
- name: Checkout repository
@@ -57,7 +61,7 @@ jobs:
5761
echo "changes=false" >> $GITHUB_OUTPUT
5862
fi
5963
60-
- name: Commit version changes
64+
- name: Commit version changes (PR only - no push)
6165
if: steps.git_status.outputs.changes == 'true'
6266
run: |
6367
git config --local user.email "action@github.com"
@@ -72,7 +76,7 @@ jobs:
7276
fi
7377
7478
git commit -m "🤖 Auto-increment version to ${{ steps.version_update.outputs.new_version }} (prod: ${{ steps.version_update.outputs.prod_version }}, dev: ${{ steps.version_update.outputs.dev_version }})"
75-
git push
79+
# Note: Not pushing changes in PR context - they will be available for review
7680
7781
- name: Log in to the Container registry
7882
uses: docker/login-action@v3
@@ -87,13 +91,10 @@ jobs:
8791
with:
8892
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
8993
tags: |
90-
type=raw,value=latest
91-
type=raw,value=${{ steps.version_update.outputs.new_version }}
92-
type=raw,value=${{ steps.version_update.outputs.prod_version }},enable={{isBranch 'master'}}
93-
type=ref,event=branch
94+
type=raw,value=pr-${{ github.event.number }}
95+
type=raw,value=${{ steps.version_update.outputs.new_version }}-pr-${{ github.event.number }}
9496
type=ref,event=pr
95-
type=semver,pattern={{version}}
96-
type=sha,prefix=
97+
type=sha,prefix=pr-${{ github.event.number }}-
9798
9899
- name: Set up Docker Buildx
99100
uses: docker/setup-buildx-action@v3
@@ -108,68 +109,46 @@ jobs:
108109
cache-from: type=gha
109110
cache-to: type=gha,mode=max
110111

111-
- name: Create version branch (stable releases only)
112-
if: steps.git_status.outputs.changes == 'true' && steps.version_update.outputs.is_stable == 'true' && steps.version_update.outputs.is_master == 'true'
113-
run: |
114-
# Create a new branch for this stable version
115-
git checkout -b "release/v${{ steps.version_update.outputs.new_version }}"
116-
git push origin "release/v${{ steps.version_update.outputs.new_version }}"
117-
118-
# Switch back to main branch
119-
git checkout ${{ github.ref_name }}
120-
121-
- name: Generate release notes (stable releases only)
122-
if: steps.git_status.outputs.changes == 'true' && steps.version_update.outputs.is_stable == 'true' && steps.version_update.outputs.is_master == 'true'
123-
id: release_notes
124-
run: |
125-
# Make script executable
126-
chmod +x .github/scripts/generate-release-notes.js
112+
- name: Add PR comment with build info
113+
uses: actions/github-script@v7
114+
with:
115+
script: |
116+
const comment = `## 🚀 CI/CD Build Summary for PR #${{ github.event.number }}
127117
128-
# Generate release notes using the script
129-
node .github/scripts/generate-release-notes.js "${{ steps.version_update.outputs.new_version }}"
118+
**Build Status:** ✅ Success
119+
**Version:** ${{ steps.version_update.outputs.new_version }}
120+
**Docker Images Built:**
121+
- \`${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:pr-${{ github.event.number }}\`
122+
- \`${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version_update.outputs.new_version }}-pr-${{ github.event.number }}\`
130123
131-
- name: Create Git Tag (stable releases only)
132-
if: steps.git_status.outputs.changes == 'true' && steps.version_update.outputs.is_stable == 'true' && steps.version_update.outputs.is_master == 'true'
133-
run: |
134-
git tag v${{ steps.version_update.outputs.new_version }}
135-
git push origin v${{ steps.version_update.outputs.new_version }}
124+
**Files Updated:**
125+
- \`apps/web/projectData.ts\` - Updated to ${{ steps.version_update.outputs.new_version }}
126+
- \`version.json\` - prod: ${{ steps.version_update.outputs.prod_version }}, dev: ${{ steps.version_update.outputs.dev_version }}
127+
${steps.version_update.outputs.version_file ? `- \`Versions/${{ steps.version_update.outputs.version_file }}\` - New version file created` : ''}
136128
137-
- name: Create GitHub Release (stable releases only)
138-
if: steps.git_status.outputs.changes == 'true' && steps.version_update.outputs.is_stable == 'true' && steps.version_update.outputs.is_master == 'true'
139-
env:
140-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
141-
run: |
142-
# Use version file if created, otherwise use generated release notes
143-
if [ -f "Versions/${{ steps.version_update.outputs.version_file }}" ]; then
144-
NOTES_FILE="Versions/${{ steps.version_update.outputs.version_file }}"
145-
else
146-
NOTES_FILE="release-notes.md"
147-
fi
129+
> **Note:** This is a PR build. No releases or version branches will be created until the PR is merged.`;
148130
149-
# Create release using GitHub CLI
150-
gh release create v${{ steps.version_update.outputs.new_version }} \
151-
--title "Release v${{ steps.version_update.outputs.new_version }}" \
152-
--notes-file "$NOTES_FILE" \
153-
--latest
131+
github.rest.issues.createComment({
132+
issue_number: context.issue.number,
133+
owner: context.repo.owner,
134+
repo: context.repo.repo,
135+
body: comment
136+
});
154137
155138
- name: Output summary
156139
run: |
157-
echo "## 🚀 Comprehensive Version Update & Build Summary" >> $GITHUB_STEP_SUMMARY
140+
echo "## 🚀 PR Build Summary for #${{ github.event.number }}" >> $GITHUB_STEP_SUMMARY
158141
echo "- **Previous version:** ${{ steps.version_update.outputs.previous_version }}" >> $GITHUB_STEP_SUMMARY
159142
echo "- **New version:** ${{ steps.version_update.outputs.new_version }}" >> $GITHUB_STEP_SUMMARY
160143
echo "- **Production version:** ${{ steps.version_update.outputs.prod_version }}" >> $GITHUB_STEP_SUMMARY
161144
echo "- **Development version:** ${{ steps.version_update.outputs.dev_version }}" >> $GITHUB_STEP_SUMMARY
162-
echo "- **Branch:** ${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY
163-
echo "- **Stable release:** ${{ steps.version_update.outputs.is_stable }}" >> $GITHUB_STEP_SUMMARY
145+
echo "- **PR Author:** ${{ github.event.pull_request.user.login }}" >> $GITHUB_STEP_SUMMARY
146+
echo "- **Author Association:** ${{ github.event.pull_request.author_association }}" >> $GITHUB_STEP_SUMMARY
164147
echo "" >> $GITHUB_STEP_SUMMARY
165148
166149
echo "### 🐳 Docker Images Built" >> $GITHUB_STEP_SUMMARY
167-
echo "- \`${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest\`" >> $GITHUB_STEP_SUMMARY
168-
echo "- \`${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version_update.outputs.new_version }}\`" >> $GITHUB_STEP_SUMMARY
169-
170-
if [ "${{ steps.version_update.outputs.is_master }}" == "true" ]; then
171-
echo "- \`${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version_update.outputs.prod_version }}\`" >> $GITHUB_STEP_SUMMARY
172-
fi
150+
echo "- \`${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:pr-${{ github.event.number }}\`" >> $GITHUB_STEP_SUMMARY
151+
echo "- \`${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version_update.outputs.new_version }}-pr-${{ github.event.number }}\`" >> $GITHUB_STEP_SUMMARY
173152
echo "" >> $GITHUB_STEP_SUMMARY
174153
175154
echo "### 📁 Files Updated" >> $GITHUB_STEP_SUMMARY
@@ -181,19 +160,7 @@ jobs:
181160
fi
182161
echo "" >> $GITHUB_STEP_SUMMARY
183162
184-
if [ "${{ steps.version_update.outputs.is_stable }}" == "true" ] && [ "${{ steps.version_update.outputs.is_master }}" == "true" ]; then
185-
echo "### 🏷️ Release Created" >> $GITHUB_STEP_SUMMARY
186-
echo "- **Tag:** \`v${{ steps.version_update.outputs.new_version }}\`" >> $GITHUB_STEP_SUMMARY
187-
echo "- **Branch:** \`release/v${{ steps.version_update.outputs.new_version }}\`" >> $GITHUB_STEP_SUMMARY
188-
echo "- **Release:** [v${{ steps.version_update.outputs.new_version }}](https://github.com/${{ github.repository }}/releases/tag/v${{ steps.version_update.outputs.new_version }})" >> $GITHUB_STEP_SUMMARY
189-
if [ -n "${{ steps.version_update.outputs.version_file }}" ]; then
190-
echo "- **Version File:** \`Versions/${{ steps.version_update.outputs.version_file }}\`" >> $GITHUB_STEP_SUMMARY
191-
fi
192-
else
193-
echo "### ⚠️ Development Build" >> $GITHUB_STEP_SUMMARY
194-
if [ "${{ steps.version_update.outputs.is_master }}" != "true" ]; then
195-
echo "This is a development branch build. No GitHub release or version branch created." >> $GITHUB_STEP_SUMMARY
196-
else
197-
echo "This is a pre-release version (contains alpha, beta, canary, etc.). No GitHub release or version branch created." >> $GITHUB_STEP_SUMMARY
198-
fi
199-
fi
163+
echo "### ℹ️ PR Build Notes" >> $GITHUB_STEP_SUMMARY
164+
echo "This is a pull request build. No releases, tags, or version branches will be created." >> $GITHUB_STEP_SUMMARY
165+
echo "Version changes are committed locally for review but not pushed to the repository." >> $GITHUB_STEP_SUMMARY
166+
echo "Once the PR is merged, you may want to run a separate workflow for production deployments." >> $GITHUB_STEP_SUMMARY

apps/web/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"geist": "^1.5.1",
3333
"lucide-react": "^0.546.0",
3434
"marked-react": "^3.0.2",
35-
"next": "^16.0.7",
35+
"next": "^16.0.10",
3636
"next-themes": "^0.4.6",
3737
"prism-react-renderer": "^2.4.1",
3838
"radix-ui": "^1.4.3",

0 commit comments

Comments
 (0)