Improve deployment and blog safety
自动部署 / deploy (push) Failing after 2m28s

This commit is contained in:
biss committed 2026-11-30 20:18:40 +08:00
1 parent f558907f09
commit ac7991a37c
8 files changed
+79 -40

No files matched your search

+12 -12
View File
@@ -17,37 +17,37 @@ jobs:
uses: actions/checkout@v4
with:
ref: master
- name: 缓存项目 npm 包
id: cache-node-modules
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-nodeModules-${{ hashFiles('package-lock.json') }}-${{ hashFiles('package.json') }}
restore-keys: |
${{ runner.os }}-nodeModules-
- name: 安装 Node
uses: actions/setup-node@v4
with:
node-version: "22.x"
- name: 安装依赖
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: |
npm install
npm ci
- name: 同步 Astro 类型
run: |
npm run clean
- name: 生成静态文件
run: |
npm run build
- name: 检查部署密钥
env:
DEPLOY_HOOK_KEY: ${{ secrets.DEPLOY_HOOK_KEY }}
run: test -n "$DEPLOY_HOOK_KEY"
- name: 部署到 page 分支
env:
COMMIT_MESSAGE: ${{ gitea.event.head_commit.message }}
run: |
cd ./dist
git init
git config user.name "${{ gitea.actor }}"
git config user.email "${{ gitea.actor }}@noreply.gitea.io"
git add .
git commit -m "${{ gitea.event.head_commit.message }} -- [$(date +"%Z %Y-%m-%d %A %H:%M:%S")]"
git commit -m "${COMMIT_MESSAGE:-Deploy} -- [$(date +"%Z %Y-%m-%d %A %H:%M:%S")]"
git push --force --quiet "https://${{ gitea.actor }}:${{ secrets.DEPLOY_TOKEN }}@git.biss.click/biss/blog.git" master:page
- name: 触发服务器部署
env:
DEPLOY_HOOK_KEY: ${{ secrets.DEPLOY_HOOK_KEY }}
run: |
curl -k -X POST "https://panel.biss.click/hook?access_key=1XJG8IvYTSZVvD5dpm86GYIpQxgxBcucULnX1MFskZSKayXU"
test -n "$DEPLOY_HOOK_KEY"
curl --fail --silent --show-error --get --data-urlencode "access_key=$DEPLOY_HOOK_KEY" -X POST "https://panel.biss.click/hook"
+24 -9
View File
@@ -2,6 +2,13 @@ function renderTalks() {
const talkContainer = document.querySelector('#talk');
if (!talkContainer) return;
const config = window.SITE_CONFIG?.talks || {};
const escapeHtml = (value) => String(value ?? '').replace(/[&<>"']/g, (char) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[char]);
const safeUrl = (value) => {
try {
const url = new URL(value, window.location.origin);
return ['http:', 'https:'].includes(url.protocol) ? url.href : '';
} catch { return ''; }
};
talkContainer.innerHTML = '';
const generateIconSVG = () => {
return `<svg viewBox="0 0 512 512"xmlns="http://www.w3.org/2000/svg"class="is-badge icon"><path d="m512 268c0 17.9-4.3 34.5-12.9 49.7s-20.1 27.1-34.6 35.4c.4 2.7.6 6.9.6 12.6 0 27.1-9.1 50.1-27.1 69.1-18.1 19.1-39.9 28.6-65.4 28.6-11.4 0-22.3-2.1-32.6-6.3-8 16.4-19.5 29.6-34.6 39.7-15 10.2-31.5 15.2-49.4 15.2-18.3 0-34.9-4.9-49.7-14.9-14.9-9.9-26.3-23.2-34.3-40-10.3 4.2-21.1 6.3-32.6 6.3-25.5 0-47.4-9.5-65.7-28.6-18.3-19-27.4-42.1-27.4-69.1 0-3 .4-7.2 1.1-12.6-14.5-8.4-26-20.2-34.6-35.4-8.5-15.2-12.8-31.8-12.8-49.7 0-19 4.8-36.5 14.3-52.3s22.3-27.5 38.3-35.1c-4.2-11.4-6.3-22.9-6.3-34.3 0-27 9.1-50.1 27.4-69.1s40.2-28.6 65.7-28.6c11.4 0 22.3 2.1 32.6 6.3 8-16.4 19.5-29.6 34.6-39.7 15-10.1 31.5-15.2 49.4-15.2s34.4 5.1 49.4 15.1c15 10.1 26.6 23.3 34.6 39.7 10.3-4.2 21.1-6.3 32.6-6.3 25.5 0 47.3 9.5 65.4 28.6s27.1 42.1 27.1 69.1c0 12.6-1.9 24-5.7 34.3 16 7.6 28.8 19.3 38.3 35.1 9.5 15.9 14.3 33.4 14.3 52.4zm-266.9 77.1 105.7-158.3c2.7-4.2 3.5-8.8 2.6-13.7-1-4.9-3.5-8.8-7.7-11.4-4.2-2.7-8.8-3.6-13.7-2.9-5 .8-9 3.2-12 7.4l-93.1 140-42.9-42.8c-3.8-3.8-8.2-5.6-13.1-5.4-5 .2-9.3 2-13.1 5.4-3.4 3.4-5.1 7.7-5.1 12.9 0 5.1 1.7 9.4 5.1 12.9l58.9 58.9 2.9 2.3c3.4 2.3 6.9 3.4 10.3 3.4 6.7-.1 11.8-2.9 15.2-8.7z"fill="#1da1f2"></path></svg>`;
@@ -117,9 +124,9 @@ function renderTalks() {
const parsedUrl = new URL(url, window.location.origin);
if (!parsedUrl.searchParams.has('fmt')) parsedUrl.searchParams.set('fmt', 'webp');
if (!parsedUrl.searchParams.has('q')) parsedUrl.searchParams.set('q', '75');
return parsedUrl.toString();
return safeUrl(parsedUrl.toString());
} catch {
return url;
return '';
}
};
@@ -145,8 +152,11 @@ function renderTalks() {
const formatTalk = (item) => {
const date = formatTime(item.created_at);
let content = item.content || '';
content = content.replace(/\[(.*?)\]\((.*?)\)/g, `<a href="$2" target="_blank" rel="nofollow noopener">@$1</a>`)
let content = escapeHtml(item.content || '');
content = content.replace(/\[(.*?)\]\((.*?)\)/g, (match, label, href) => {
const url = safeUrl(href);
return url ? `<a href="${escapeHtml(url)}" target="_blank" rel="nofollow noopener">@${label}</a>` : label;
})
.replace(/- \[ \]/g, '⚪')
.replace(/- \[x\]/g, '⚫')
.replace(/\n/g, '<br>');
@@ -159,6 +169,7 @@ function renderTalks() {
imgDiv.className = 'zone_imgbox';
images.forEach(url => {
const imageUrl = withImageParams(url);
if (!imageUrl) return;
const link = document.createElement('a');
link.href = imageUrl;
link.setAttribute('data-fancybox', 'gallery');
@@ -208,17 +219,20 @@ function renderTalks() {
}
}
siteUrl = safeUrl(siteUrl);
// 输出 HTML 结构
if (siteUrl) {
content += `
<div class="shuoshuo-external-link">
<a class="external-link" href="${siteUrl}" target="_blank" rel="nofollow noopener">
<a class="external-link" href="${escapeHtml(siteUrl)}" target="_blank" rel="nofollow noopener">
<div class="external-link-left" style="background-image:url(${extensionBack})"></div>
<div class="external-link-right">
<div class="external-link-title">${title}</div>
<div class="external-link-title">${escapeHtml(title)}</div>
<div>点击跳转<i class="fa-solid fa-angle-right"></i></div>
</div>
</a>
</div>`;
}
}
@@ -238,7 +252,7 @@ function renderTalks() {
// 视频
if (item.extension_type === 'VIDEO' && item.extension) {
const video = item.extension;
if (video.startsWith('BV')) {
if (/^BV[a-zA-Z0-9]+$/.test(video)) {
const bilibiliUrl = `https://www.bilibili.com/blackboard/html5mobileplayer.html?bvid=${video}&as_wide=1&high_quality=1&danmaku=0`;
content += `
<div style="position: relative; padding: 30% 45%; margin-top: 10px;">
@@ -248,7 +262,7 @@ function renderTalks() {
allowfullscreen="true"
loading="lazy"></iframe>
</div>`;
} else {
} else if (/^[a-zA-Z0-9_-]{11}$/.test(video)) {
const youtubeUrl = `https://www.youtube.com/embed/${video}`;
content += `
<div style="position: relative; padding: 30% 45%; margin-top: 10px;">
@@ -287,7 +301,8 @@ function renderTalks() {
info.className = 'info';
const nick = document.createElement('span');
nick.className = 'talk_nick';
nick.innerHTML = `${item.user} ${generateIconSVG()}`;
nick.textContent = `${item.user} `;
nick.insertAdjacentHTML('beforeend', generateIconSVG());
const date = document.createElement('span');
date.className = 'talk_date';
date.textContent = item.date;
+1 -1
View File
@@ -18,7 +18,7 @@ function indexTalk() {
function toText(ls) {
return ls.map(item => {
let c = item.content || '';
let c = String(item.content || '').replace(/[&<>"']/g, char => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[char]);
const hasImg = /\!\[.*?\]\(.*?\)/.test(c);
const hasLink = /\[.*?\]\(.*?\)/.test(c);
Loaded 3 of 8 files, more files were not shown because too many files have changed in this diff. Show more