1715
This commit is contained in:
1 parent
5752b53591
commit
4cc9f0d5e1
3 files changed
+91
-83
No files matched your search
@@ -60,7 +60,7 @@ jobs:
|
|||||||
if echo "$COMMIT_MESSAGE" | grep -qE "^(feat|fix|chore|docs|style|refactor|test): "; then
|
if echo "$COMMIT_MESSAGE" | grep -qE "^(feat|fix|chore|docs|style|refactor|test): "; then
|
||||||
echo "✅ 提交信息符合规范"
|
echo "✅ 提交信息符合规范"
|
||||||
else
|
else
|
||||||
echo "⚠️ 提交信息格式建议: feat/fix/chore/docs/style/refactor/test: description"
|
echo "⚠️ 提交信息格式建议: feat/fix/chore/docs/style/refactor/test: description"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Check for new commits (only for cron)
|
- name: Check for new commits (only for cron)
|
||||||
@@ -201,6 +201,29 @@ jobs:
|
|||||||
path: public/
|
path: public/
|
||||||
retention-days: 1
|
retention-days: 1
|
||||||
|
|
||||||
|
- name: Upload build hash to UpYun
|
||||||
|
env:
|
||||||
|
UPYUN_SERVICE: ${{ secrets.UPYUN_BUCKET }}
|
||||||
|
UPYUN_OPERATOR: ${{ secrets.UPYUN_OPERATOR }}
|
||||||
|
UPYUN_PASSWORD: ${{ secrets.UPYUN_PASSWORD }}
|
||||||
|
run: |
|
||||||
|
echo "📤 上传 build_hash 到 UpYun..."
|
||||||
|
|
||||||
|
UPX_VERSION="0.4.9"
|
||||||
|
UPX_URL="https://collection.b0.upaiyun.com/softwares/upx/upx_${UPX_VERSION}_linux_amd64.tar.gz"
|
||||||
|
UPX_BIN="/tmp/upyun-upx"
|
||||||
|
|
||||||
|
if [ ! -x "$UPX_BIN" ]; then
|
||||||
|
curl -sL "$UPX_URL" -o /tmp/upx.tar.gz
|
||||||
|
tar -xzf /tmp/upx.tar.gz -C /tmp
|
||||||
|
mv /tmp/upx "$UPX_BIN"
|
||||||
|
chmod +x "$UPX_BIN"
|
||||||
|
fi
|
||||||
|
|
||||||
|
"$UPX_BIN" login "$UPYUN_SERVICE" "$UPYUN_OPERATOR" "$UPYUN_PASSWORD"
|
||||||
|
"$UPX_BIN" put public/.build_hash /__build_hash
|
||||||
|
echo "✅ build_hash 已上传到 UpYun"
|
||||||
|
|
||||||
- name: Push Image Optimizations
|
- name: Push Image Optimizations
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
run: |
|
run: |
|
||||||
@@ -238,7 +261,6 @@ jobs:
|
|||||||
timeout-minutes: 10
|
timeout-minutes: 10
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
actions: read
|
|
||||||
needs: build
|
needs: build
|
||||||
outputs:
|
outputs:
|
||||||
deployed: ${{ steps.check.outputs.deployed }}
|
deployed: ${{ steps.check.outputs.deployed }}
|
||||||
@@ -251,49 +273,35 @@ jobs:
|
|||||||
id: start-edgeone
|
id: start-edgeone
|
||||||
run: echo "start_time=$(date +%s)" >> $GITHUB_OUTPUT
|
run: echo "start_time=$(date +%s)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Get last successful run info
|
- name: Get last build hash from UpYun
|
||||||
id: last-run
|
|
||||||
run: |
|
|
||||||
echo "🔍 查找上一次成功部署的 hash..."
|
|
||||||
|
|
||||||
# 获取上一个成功的 workflow run(排除当前 run)
|
|
||||||
LAST_RUN=$(gh api repos/${{ github.repository }}/actions/runs \
|
|
||||||
--jq '.workflow_runs[] | select(.conclusion == "success") | select(.id != $RUN_ID) | {id: .id, head_sha: .head_sha}' \
|
|
||||||
--paginate \
|
|
||||||
--limit 10 \
|
|
||||||
-F run_id=${{ github.run_id }} 2>/dev/null | head -2)
|
|
||||||
|
|
||||||
if [ -z "$LAST_RUN" ]; then
|
|
||||||
echo "没有找到上一次成功运行的记录"
|
|
||||||
echo "last_run_id=" >> $GITHUB_OUTPUT
|
|
||||||
echo "last_hash=" >> $GITHUB_OUTPUT
|
|
||||||
else
|
|
||||||
LAST_RUN_ID=$(echo "$LAST_RUN" | jq -r '.id')
|
|
||||||
LAST_SHA=$(echo "$LAST_RUN" | jq -r '.head_sha')
|
|
||||||
echo "上次成功运行 ID: $LAST_RUN_ID"
|
|
||||||
echo "上次成功运行 SHA: $LAST_SHA"
|
|
||||||
echo "last_run_id=${LAST_RUN_ID}" >> $GITHUB_OUTPUT
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Download last artifact and get hash
|
|
||||||
id: last-hash
|
id: last-hash
|
||||||
if: steps.last-run.outputs.last_run_id != ''
|
env:
|
||||||
|
UPYUN_SERVICE: ${{ secrets.UPYUN_BUCKET }}
|
||||||
|
UPYUN_OPERATOR: ${{ secrets.UPYUN_OPERATOR }}
|
||||||
|
UPYUN_PASSWORD: ${{ secrets.UPYUN_PASSWORD }}
|
||||||
run: |
|
run: |
|
||||||
LAST_RUN_ID="${{ steps.last-run.outputs.last_run_id }}"
|
echo "🔍 从 UpYun 获取上次部署的 hash..."
|
||||||
|
|
||||||
echo "� 下载上次成功的 artifact..."
|
UPX_VERSION="0.4.9"
|
||||||
gh api repos/${{ github.repository }}/actions/runs/$LAST_RUN_ID/artifacts \
|
UPX_URL="https://collection.b0.upaiyun.com/softwares/upx/upx_${UPX_VERSION}_linux_amd64.tar.gz"
|
||||||
--jq '.artifacts[] | select(.name == "hugo-public") | .id' > /tmp/last_artifact_id.txt
|
UPX_BIN="/tmp/upyun-upx"
|
||||||
|
|
||||||
LAST_ARTIFACT_ID=$(cat /tmp/last_artifact_id.txt)
|
if [ ! -x "$UPX_BIN" ]; then
|
||||||
|
curl -sL "$UPX_URL" -o /tmp/upx.tar.gz
|
||||||
if [ -n "$LAST_ARTIFACT_ID" ]; then
|
tar -xzf /tmp/upx.tar.gz -C /tmp
|
||||||
gh api repos/${{ github.repository }}/actions/artifacts/$LAST_ARTIFACT_ID/archive --output /tmp/last_artifact.zip
|
mv /tmp/upx "$UPX_BIN"
|
||||||
unzip -p /tmp/last_artifact.zip .build_hash 2>/dev/null || echo ""
|
chmod +x "$UPX_BIN"
|
||||||
LAST_HASH=$(unzip -p /tmp/last_artifact.zip .build_hash 2>/dev/null)
|
|
||||||
echo "上次部署 hash: $LAST_HASH"
|
|
||||||
echo "last_hash=${LAST_HASH}" >> $GITHUB_OUTPUT
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
"$UPX_BIN" login "$UPYUN_SERVICE" "$UPYUN_OPERATOR" "$UPYUN_PASSWORD"
|
||||||
|
|
||||||
|
LAST_HASH=$("$UPX_BIN" get /__build_hash 2>/dev/null || echo "")
|
||||||
|
if [ -z "$LAST_HASH" ]; then
|
||||||
|
echo "⚠️ 没有找到上次部署的 hash(首次部署)"
|
||||||
|
else
|
||||||
|
echo "上次部署 hash: $LAST_HASH"
|
||||||
|
fi
|
||||||
|
echo "last_hash=${LAST_HASH}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Checkout code (for scripts)
|
- name: Checkout code (for scripts)
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -372,7 +380,6 @@ jobs:
|
|||||||
timeout-minutes: 20
|
timeout-minutes: 20
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
actions: read
|
|
||||||
needs: build
|
needs: build
|
||||||
outputs:
|
outputs:
|
||||||
deployed: ${{ steps.check.outputs.deployed }}
|
deployed: ${{ steps.check.outputs.deployed }}
|
||||||
@@ -385,49 +392,35 @@ jobs:
|
|||||||
id: start-upyun
|
id: start-upyun
|
||||||
run: echo "start_time=$(date +%s)" >> $GITHUB_OUTPUT
|
run: echo "start_time=$(date +%s)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Get last successful run info
|
- name: Get last build hash from UpYun
|
||||||
id: last-run
|
|
||||||
run: |
|
|
||||||
echo "🔍 查找上一次成功部署的 hash..."
|
|
||||||
|
|
||||||
# 获取上一个成功的 workflow run(排除当前 run)
|
|
||||||
LAST_RUN=$(gh api repos/${{ github.repository }}/actions/runs \
|
|
||||||
--jq '.workflow_runs[] | select(.conclusion == "success") | select(.id != $RUN_ID) | {id: .id, head_sha: .head_sha}' \
|
|
||||||
--paginate \
|
|
||||||
--limit 10 \
|
|
||||||
-F run_id=${{ github.run_id }} 2>/dev/null | head -2)
|
|
||||||
|
|
||||||
if [ -z "$LAST_RUN" ]; then
|
|
||||||
echo "没有找到上一次成功运行的记录"
|
|
||||||
echo "last_run_id=" >> $GITHUB_OUTPUT
|
|
||||||
echo "last_hash=" >> $GITHUB_OUTPUT
|
|
||||||
else
|
|
||||||
LAST_RUN_ID=$(echo "$LAST_RUN" | jq -r '.id')
|
|
||||||
LAST_SHA=$(echo "$LAST_RUN" | jq -r '.head_sha')
|
|
||||||
echo "上次成功运行 ID: $LAST_RUN_ID"
|
|
||||||
echo "上次成功运行 SHA: $LAST_SHA"
|
|
||||||
echo "last_run_id=${LAST_RUN_ID}" >> $GITHUB_OUTPUT
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Download last artifact and get hash
|
|
||||||
id: last-hash
|
id: last-hash
|
||||||
if: steps.last-run.outputs.last_run_id != ''
|
env:
|
||||||
|
UPYUN_SERVICE: ${{ secrets.UPYUN_BUCKET }}
|
||||||
|
UPYUN_OPERATOR: ${{ secrets.UPYUN_OPERATOR }}
|
||||||
|
UPYUN_PASSWORD: ${{ secrets.UPYUN_PASSWORD }}
|
||||||
run: |
|
run: |
|
||||||
LAST_RUN_ID="${{ steps.last-run.outputs.last_run_id }}"
|
echo "🔍 从 UpYun 获取上次部署的 hash..."
|
||||||
|
|
||||||
echo "� 下载上次成功的 artifact..."
|
UPX_VERSION="0.4.9"
|
||||||
gh api repos/${{ github.repository }}/actions/runs/$LAST_RUN_ID/artifacts \
|
UPX_URL="https://collection.b0.upaiyun.com/softwares/upx/upx_${UPX_VERSION}_linux_amd64.tar.gz"
|
||||||
--jq '.artifacts[] | select(.name == "hugo-public") | .id' > /tmp/last_artifact_id.txt
|
UPX_BIN="/tmp/upyun-upx"
|
||||||
|
|
||||||
LAST_ARTIFACT_ID=$(cat /tmp/last_artifact_id.txt)
|
if [ ! -x "$UPX_BIN" ]; then
|
||||||
|
curl -sL "$UPX_URL" -o /tmp/upx.tar.gz
|
||||||
if [ -n "$LAST_ARTIFACT_ID" ]; then
|
tar -xzf /tmp/upx.tar.gz -C /tmp
|
||||||
gh api repos/${{ github.repository }}/actions/artifacts/$LAST_ARTIFACT_ID/archive --output /tmp/last_artifact.zip
|
mv /tmp/upx "$UPX_BIN"
|
||||||
unzip -p /tmp/last_artifact.zip .build_hash 2>/dev/null || echo ""
|
chmod +x "$UPX_BIN"
|
||||||
LAST_HASH=$(unzip -p /tmp/last_artifact.zip .build_hash 2>/dev/null)
|
|
||||||
echo "上次部署 hash: $LAST_HASH"
|
|
||||||
echo "last_hash=${LAST_HASH}" >> $GITHUB_OUTPUT
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
"$UPX_BIN" login "$UPYUN_SERVICE" "$UPYUN_OPERATOR" "$UPYUN_PASSWORD"
|
||||||
|
|
||||||
|
LAST_HASH=$("$UPX_BIN" get /__build_hash 2>/dev/null || echo "")
|
||||||
|
if [ -z "$LAST_HASH" ]; then
|
||||||
|
echo "⚠️ 没有找到上次部署的 hash(首次部署)"
|
||||||
|
else
|
||||||
|
echo "上次部署 hash: $LAST_HASH"
|
||||||
|
fi
|
||||||
|
echo "last_hash=${LAST_HASH}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Checkout code (for scripts)
|
- name: Checkout code (for scripts)
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -864,7 +857,6 @@ jobs:
|
|||||||
if [ "${{ needs.deploy-upyun.result }}" = "failure" ]; then FAILURES=$(printf "%s\n 🔴 Deploy UpYun" "$FAILURES"); fi
|
if [ "${{ needs.deploy-upyun.result }}" = "failure" ]; then FAILURES=$(printf "%s\n 🔴 Deploy UpYun" "$FAILURES"); fi
|
||||||
if [ "${{ needs.finalize.result }}" = "failure" ]; then FAILURES=$(printf "%s\n 🔴 Finalize" "$FAILURES"); fi
|
if [ "${{ needs.finalize.result }}" = "failure" ]; then FAILURES=$(printf "%s\n 🔴 Finalize" "$FAILURES"); fi
|
||||||
|
|
||||||
# 检查每个阶段的状态
|
|
||||||
PRECHECK_STATUS=$([ "${{ needs.pre-check.result }}" = "success" ] && echo "✅ 成功" || ([ "${{ needs.pre-check.result }}" = "failure" ] && echo "❌ 失败" || echo "⏭️ 跳过"))
|
PRECHECK_STATUS=$([ "${{ needs.pre-check.result }}" = "success" ] && echo "✅ 成功" || ([ "${{ needs.pre-check.result }}" = "failure" ] && echo "❌ 失败" || echo "⏭️ 跳过"))
|
||||||
BUILD_STATUS=$([ "${{ needs.build.result }}" = "success" ] && echo "✅ 成功" || ([ "${{ needs.build.result }}" = "failure" ] && echo "❌ 失败" || echo "⏭️ 跳过"))
|
BUILD_STATUS=$([ "${{ needs.build.result }}" = "success" ] && echo "✅ 成功" || ([ "${{ needs.build.result }}" = "failure" ] && echo "❌ 失败" || echo "⏭️ 跳过"))
|
||||||
EDGEONE_STATUS=$([ "${{ needs.deploy-edgeone.result }}" = "success" ] && echo "✅ 成功" || ([ "${{ needs.deploy-edgeone.result }}" = "failure" ] && echo "❌ 失败" || echo "⏭️ 跳过"))
|
EDGEONE_STATUS=$([ "${{ needs.deploy-edgeone.result }}" = "success" ] && echo "✅ 成功" || ([ "${{ needs.deploy-edgeone.result }}" = "failure" ] && echo "❌ 失败" || echo "⏭️ 跳过"))
|
||||||
@@ -915,7 +907,6 @@ jobs:
|
|||||||
if [ "${{ needs.deploy-upyun.result }}" = "failure" ]; then FAILURES=$(printf "%s\n 🔴 Deploy UpYun" "$FAILURES"); fi
|
if [ "${{ needs.deploy-upyun.result }}" = "failure" ]; then FAILURES=$(printf "%s\n 🔴 Deploy UpYun" "$FAILURES"); fi
|
||||||
if [ "${{ needs.finalize.result }}" = "failure" ]; then FAILURES=$(printf "%s\n 🔴 Finalize" "$FAILURES"); fi
|
if [ "${{ needs.finalize.result }}" = "failure" ]; then FAILURES=$(printf "%s\n 🔴 Finalize" "$FAILURES"); fi
|
||||||
|
|
||||||
# 检查每个阶段的状态
|
|
||||||
PRECHECK_STATUS=$([ "${{ needs.pre-check.result }}" = "success" ] && echo "✅ 成功" || ([ "${{ needs.pre-check.result }}" = "failure" ] && echo "❌ 失败" || echo "⏭️ 跳过"))
|
PRECHECK_STATUS=$([ "${{ needs.pre-check.result }}" = "success" ] && echo "✅ 成功" || ([ "${{ needs.pre-check.result }}" = "failure" ] && echo "❌ 失败" || echo "⏭️ 跳过"))
|
||||||
BUILD_STATUS=$([ "${{ needs.build.result }}" = "success" ] && echo "✅ 成功" || ([ "${{ needs.build.result }}" = "failure" ] && echo "❌ 失败" || echo "⏭️ 跳过"))
|
BUILD_STATUS=$([ "${{ needs.build.result }}" = "success" ] && echo "✅ 成功" || ([ "${{ needs.build.result }}" = "failure" ] && echo "❌ 失败" || echo "⏭️ 跳过"))
|
||||||
EDGEONE_STATUS=$([ "${{ needs.deploy-edgeone.result }}" = "success" ] && echo "✅ 成功" || ([ "${{ needs.deploy-edgeone.result }}" = "failure" ] && echo "❌ 失败" || echo "⏭️ 跳过"))
|
EDGEONE_STATUS=$([ "${{ needs.deploy-edgeone.result }}" = "success" ] && echo "✅ 成功" || ([ "${{ needs.deploy-edgeone.result }}" = "failure" ] && echo "❌ 失败" || echo "⏭️ 跳过"))
|
||||||
|
|||||||
Generated
+17
-1
@@ -11,7 +11,8 @@
|
|||||||
"js-yaml": "^4.1.1",
|
"js-yaml": "^4.1.1",
|
||||||
"marked": "^18.0.4",
|
"marked": "^18.0.4",
|
||||||
"rss-parser": "^3.13.0",
|
"rss-parser": "^3.13.0",
|
||||||
"sqlite3": "^5.1.7"
|
"sqlite3": "^5.1.7",
|
||||||
|
"yaml": "^2.9.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"edgeone": "^1.2.29",
|
"edgeone": "^1.2.29",
|
||||||
@@ -14111,6 +14112,21 @@
|
|||||||
"resolved": "https://registry.npmmirror.com/yallist/-/yallist-4.0.0.tgz",
|
"resolved": "https://registry.npmmirror.com/yallist/-/yallist-4.0.0.tgz",
|
||||||
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A=="
|
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A=="
|
||||||
},
|
},
|
||||||
|
"node_modules/yaml": {
|
||||||
|
"version": "2.9.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.9.0.tgz",
|
||||||
|
"integrity": "sha512-2AvhNX3mb8zd6Zy7INTtSpl1F15HW6Wnqj0srWlkKLcpYl/gMIMJiyuGq2KeI2YFxUPjdlB+3Lc10seMLtL4cA==",
|
||||||
|
"license": "ISC",
|
||||||
|
"bin": {
|
||||||
|
"yaml": "bin.mjs"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 14.6"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/eemeli"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/yargs": {
|
"node_modules/yargs": {
|
||||||
"version": "17.7.2",
|
"version": "17.7.2",
|
||||||
"resolved": "https://registry.npmmirror.com/yargs/-/yargs-17.7.2.tgz",
|
"resolved": "https://registry.npmmirror.com/yargs/-/yargs-17.7.2.tgz",
|
||||||
|
|||||||
+2
-1
@@ -6,7 +6,8 @@
|
|||||||
"js-yaml": "^4.1.1",
|
"js-yaml": "^4.1.1",
|
||||||
"marked": "^18.0.4",
|
"marked": "^18.0.4",
|
||||||
"rss-parser": "^3.13.0",
|
"rss-parser": "^3.13.0",
|
||||||
"sqlite3": "^5.1.7"
|
"sqlite3": "^5.1.7",
|
||||||
|
"yaml": "^2.9.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"edgeone": "^1.2.29",
|
"edgeone": "^1.2.29",
|
||||||
|
|||||||
Reference in new issue
Block a user