commit 44792f173aaa768df1387c962c0cd84ac9c50773
parent add748214b8e325692066515e2f0e86c4519c15a
Author: Amit Dutta <amitdutta4255@gmail.com>
Date: Sun, 21 Jun 2026 17:27:44 +0530
given full permission to ci
Diffstat:
2 files changed, 97 insertions(+), 15 deletions(-)
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
@@ -7,7 +7,7 @@ on:
workflow_dispatch:
permissions:
- contents: read
+ contents: write
pages: write
id-token: write
@@ -66,18 +66,35 @@ jobs:
with:
python-version: '3.12'
+ - name: Cache pip
+ uses: actions/cache@v4
+ with:
+ path: ~/.cache/pip
+ key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
+ restore-keys: ${{ runner.os }}-pip-
+
- name: Generate markdown files
run: |
python list.py
python md.py
- - name: Generate version file
+ - name: Generate changelog
env:
- GITHUB_SHA: ${{ github.sha }}
- GITHUB_ACTOR: ${{ github.actor }}
- GITHUB_REF_NAME: ${{ github.ref_name }}
+ BUILD_SHA: ${{ github.sha }}
+ BUILD_ACTOR: ${{ github.actor }}
+ BUILD_REF: ${{ github.ref_name }}
BUILD_TIMESTAMP: ${{ github.event.head_commit.timestamp }}
- run: python changelog.py
+ run: |
+ git log --pretty=format:"%H|%s|%an|%aI" -20 > git_log.txt
+ python changelog.py
+
+ - name: Commit CHANGELOG.md to repo
+ run: |
+ git config user.name "github-actions[bot]"
+ git config user.email "github-actions[bot]@users.noreply.github.com"
+ git add CHANGELOG.md
+ git commit -m "chore: update CHANGELOG.md [skip ci]" || echo "No changes"
+ git push
- name: Setup Node.js
uses: actions/setup-node@v4
diff --git a/changelog.py b/changelog.py
@@ -1,9 +1,9 @@
import os
from datetime import datetime, timezone
-sha = os.environ.get('GITHUB_SHA', 'unknown')
-actor = os.environ.get('GITHUB_ACTOR', 'unknown')
-ref = os.environ.get('GITHUB_REF_NAME', 'unknown')
+sha = os.environ.get('BUILD_SHA', 'unknown')
+actor = os.environ.get('BUILD_ACTOR', 'unknown')
+ref = os.environ.get('BUILD_REF', 'unknown')
timestamp = os.environ.get('BUILD_TIMESTAMP', '')
try:
@@ -12,18 +12,83 @@ try:
except:
build_time = timestamp
-content = f"""---
-title: '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="display:inline; margin-bottom:-2px; margin-right:6px;" class="lucide lucide-history"><path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><path d="M3 3v5h5"/><path d="M12 7v5l4 2"/></svg> Changelog'
-description: 'Current build information.'
+# Parse git log
+commits = []
+try:
+ with open('git_log.txt', 'r', encoding='utf-8') as f:
+ for line in f:
+ parts = line.strip().split('|')
+ if len(parts) == 4:
+ c_sha, c_msg, c_author, c_time = parts
+ try:
+ c_dt = datetime.fromisoformat(c_time).astimezone(timezone.utc)
+ c_time_fmt = c_dt.strftime('%b %d, %Y %H:%M UTC')
+ except:
+ c_time_fmt = c_time
+ commits.append({
+ 'sha': c_sha[:7],
+ 'full_sha': c_sha,
+ 'msg': c_msg,
+ 'author': c_author,
+ 'time': c_time_fmt,
+ })
+except FileNotFoundError:
+ pass
+
+ICON = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="display:inline; margin-bottom:-2px; margin-right:6px;" class="lucide lucide-history"><path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><path d="M3 3v5h5"/><path d="M12 7v5l4 2"/></svg>'
+
+# Build commit history markdown
+commit_lines = []
+for c in commits:
+ commit_url = f"https://github.com/notamitgamer/bsc/commit/{c['full_sha']}"
+ commit_lines.append(f"- [`{c['sha']}`]({commit_url}) {c['msg']} — {c['author']}, {c['time']}")
+
+commit_section = '\n'.join(commit_lines) if commit_lines else '- No commit history available.'
+
+# VitePress docs/changelog.md
+docs_content = f"""---
+title: '{ICON} Changelog'
+description: 'Current build information and recent commit history.'
---
# Build Info
+- **Build ID** — <span style="word-break: break-all;">`{sha}`</span>
+- **Triggered by** — [@{actor}](https://github.com/{actor})
+- **Branch** — `{ref}`
+- **Build time** — {build_time}
+
+## Recent Commits
+
+{commit_section}
+"""
+
+with open('docs/changelog.md', 'w', encoding='utf-8') as f:
+ f.write(docs_content)
+
+# Root CHANGELOG.md for GitHub
+root_content = f"""# Changelog
+
+> Last build: {build_time}
+
+## Latest Build
+
- **Build ID** — `{sha}`
- **Triggered by** — [@{actor}](https://github.com/{actor})
- **Branch** — `{ref}`
- **Build time** — {build_time}
+
+## Recent Commits
+
+{commit_section}
+
+---
+
+*This file is auto-generated on every deployment. For the live site, visit [code.amit.is-a.dev](https://code.amit.is-a.dev).*
+*Check [/changelog](https://code.amit.is-a.dev/changelog) on the site to verify your browser is showing the latest build.*
"""
-with open('docs/changelog.md', 'w') as f:
- f.write(content)-
\ No newline at end of file
+with open('CHANGELOG.md', 'w', encoding='utf-8') as f:
+ f.write(root_content)
+
+print(f"Generated changelog with {len(commits)} commits.")+
\ No newline at end of file