Update deploy.yml

This commit is contained in:
Vaica committed 2026-06-30 10:59:28 +08:00
1 parent a688134508
commit 2f735d4628
1 file changed
+23 -57
+23 -57
View File
@@ -112,6 +112,7 @@ jobs:
contents: write contents: write
outputs: outputs:
build_hash: ${{ steps.hash.outputs.build_hash }} build_hash: ${{ steps.hash.outputs.build_hash }}
last_hash: ${{ steps.last-hash.outputs.last_hash }}
duration: ${{ steps.end-build.outputs.duration }} duration: ${{ steps.end-build.outputs.duration }}
file_count: ${{ steps.stats.outputs.file_count }} file_count: ${{ steps.stats.outputs.file_count }}
total_size: ${{ steps.stats.outputs.total_size }} total_size: ${{ steps.stats.outputs.total_size }}
@@ -358,40 +359,11 @@ jobs:
id: start-edgeone id: start-edgeone
run: echo "start_time=$(date +%s)" >> $GITHUB_OUTPUT run: echo "start_time=$(date +%s)" >> $GITHUB_OUTPUT
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install coscmd
run: pip install -U coscmd
- name: Configure coscmd
env:
COS_SECRET_ID: ${{ secrets.COS_SECRET_ID }}
COS_SECRET_KEY: ${{ secrets.COS_SECRET_KEY }}
COS_BUCKET: ${{ secrets.COS_BUCKET }}
COS_REGION: ${{ secrets.COS_REGION }}
run: coscmd config -a $COS_SECRET_ID -s $COS_SECRET_KEY -b $COS_BUCKET -r $COS_REGION
- name: Get build hash from COS
id: hash
run: |
echo "🔍 从腾讯云 COS 获取上次部署的 hash..."
coscmd download /__build_hash /tmp/last_hash 2>/dev/null || echo ""
LAST_HASH=$(cat /tmp/last_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: Check if deployment is needed - name: Check if deployment is needed
id: check id: check
run: | run: |
CURRENT_HASH="${{ needs.build.outputs.build_hash }}" CURRENT_HASH="${{ needs.build.outputs.build_hash }}"
LAST_HASH="${{ steps.hash.outputs.last_hash }}" LAST_HASH="${{ needs.build.outputs.last_hash }}"
echo "当前 build_hash: $CURRENT_HASH" echo "当前 build_hash: $CURRENT_HASH"
echo "上次部署 hash: $LAST_HASH" echo "上次部署 hash: $LAST_HASH"
@@ -410,6 +382,25 @@ jobs:
with: with:
fetch-depth: 1 fetch-depth: 1
- name: Setup Python
if: steps.check.outputs.deployed == 'true'
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install coscmd
if: steps.check.outputs.deployed == 'true'
run: pip install -U coscmd
- name: Configure coscmd
if: steps.check.outputs.deployed == 'true'
env:
COS_SECRET_ID: ${{ secrets.COS_SECRET_ID }}
COS_SECRET_KEY: ${{ secrets.COS_SECRET_KEY }}
COS_BUCKET: ${{ secrets.COS_BUCKET }}
COS_REGION: ${{ secrets.COS_REGION }}
run: coscmd config -a $COS_SECRET_ID -s $COS_SECRET_KEY -b $COS_BUCKET -r $COS_REGION
- name: Download files from COS - name: Download files from COS
if: steps.check.outputs.deployed == 'true' if: steps.check.outputs.deployed == 'true'
id: download-files id: download-files
@@ -482,36 +473,11 @@ jobs:
id: start-upyun id: start-upyun
run: echo "start_time=$(date +%s)" >> $GITHUB_OUTPUT run: echo "start_time=$(date +%s)" >> $GITHUB_OUTPUT
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install coscmd
run: pip install -U coscmd
- name: Configure coscmd
env:
COS_SECRET_ID: ${{ secrets.COS_SECRET_ID }}
COS_SECRET_KEY: ${{ secrets.COS_SECRET_KEY }}
COS_BUCKET: ${{ secrets.COS_BUCKET }}
COS_REGION: ${{ secrets.COS_REGION }}
run: coscmd config -a $COS_SECRET_ID -s $COS_SECRET_KEY -b $COS_BUCKET -r $COS_REGION
- name: Get build hash from COS
id: hash
run: |
echo "🔍 从腾讯云 COS 获取 hash..."
coscmd download /__build_hash /tmp/current_hash 2>/dev/null || echo ""
CURRENT_HASH=$(cat /tmp/current_hash 2>/dev/null || echo "")
echo "当前 build_hash: $CURRENT_HASH"
echo "current_hash=${CURRENT_HASH}" >> $GITHUB_OUTPUT
- name: Check if deployment is needed - name: Check if deployment is needed
id: check id: check
run: | run: |
CURRENT_HASH="${{ steps.hash.outputs.current_hash }}" CURRENT_HASH="${{ needs.build.outputs.build_hash }}"
LAST_HASH="${{ needs.build.outputs.build_hash }}" LAST_HASH="${{ needs.build.outputs.last_hash }}"
echo "当前 build_hash: $CURRENT_HASH" echo "当前 build_hash: $CURRENT_HASH"
echo "上次部署 hash: $LAST_HASH" echo "上次部署 hash: $LAST_HASH"