Skip to content

Commit

Permalink
👷 新增邮票图片自动上传COS操作,用于本地开发时直接使用仓库中的图片,推送代码到仓库时检测变更的图片自动上传至COS
Browse files Browse the repository at this point in the history
  • Loading branch information
pecasha committed Apr 3, 2024
1 parent 7d5e2bc commit ad57a5c
Show file tree
Hide file tree
Showing 79 changed files with 194 additions and 110 deletions.
1 change: 0 additions & 1 deletion .env.production

This file was deleted.

58 changes: 58 additions & 0 deletions .github/workflows/images-cdn.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Upload Images to Tencent Cloud COS
on:
push:
branches:
- main
jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Get Changed Files
id: changed-files
uses: tj-actions/changed-files@v44
with:
files: static/images/**
outputs:
changed: ${{ steps.changed-files.outputs.any_changed }}
files: ${{ steps.changed-files.outputs.all_changed_files }}
upload:
needs: check
if: ${{ needs.check.outputs.changed == 'true' }}
runs-on: ubuntu-latest
env:
SECRET_ID: ${{ secrets.TENCENT_CLOUD_SECRET_ID }}
SECRET_KEY: ${{ secrets.TENCENT_CLOUD_SECRET_KEY }}
COS_BUCKET: ${{ secrets.TENCENT_CLOUD_COS_BUCKET }}
COS_REGION: ${{ secrets.TENCENT_CLOUD_COS_REGION }}
COS_PATH: ${{ secrets.TENCENT_CLOUD_COS_PATH }}
CDN_URL_PREFIX: ${{ vars.TENCENT_CLOUD_CDN_URL_PREFIX }}
CHANGED_FILES: ${{ needs.check.outputs.files }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Install coscmd
run: sudo pip install coscmd
- name: Authenticate With Tencent Cloud COS
run: coscmd config -a $SECRET_ID -s $SECRET_KEY -b $COS_BUCKET -r $COS_REGION
- name: Upload Changed Files to Tencent Cloud COS
run: |
for file in $CHANGED_FILES; do
coscmd upload $file $COS_PATH
done
- name: Install tccli
run: sudo pip install tccli
- name: Authenticate With Tencent Cloud CLI
run: tccli configure set secretId $SECRET_ID secretKey $SECRET_KEY
- name: Split Urls
id: urls
shell: python
run: |
import os, json
filenames = [os.path.basename(path) for path in os.environ["CHANGED_FILES"].split()]
formatted = [f"{os.environ['CDN_URL_PREFIX']}{path}" for path in filenames]
with open(os.environ["GITHUB_OUTPUT"], "a") as f:
f.write(f"json={json.dumps(formatted)}\n")
- name: Purge Tencent Cloud CDN Cache
run: tccli cdn PurgeUrlsCache --Urls "$(echo '${{ steps.urls.outputs.json }}')"
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,3 @@ vite.config.ts.timestamp-*
*.sw?

*.tsbuildinfo

.env.development
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"scripts": {
"dev": "vite dev",
"build": "vite build",
"build": "vite build && node ./scripts/clean.mjs",
"preview": "vite preview",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
Expand All @@ -25,9 +25,9 @@
},
"devDependencies": {
"@sveltejs/adapter-static": "^3.0.1",
"@sveltejs/kit": "^2.5.4",
"@sveltejs/kit": "^2.5.5",
"@sveltejs/vite-plugin-svelte": "^3.0.2",
"@types/node": "^20.11.30",
"@types/node": "^20.12.2",
"@vite-pwa/sveltekit": "^0.4.0",
"autoprefixer": "^10.4.19",
"flowbite": "^2.3.0",
Expand All @@ -37,10 +37,10 @@
"postcss": "^8.4.38",
"postcss-load-config": "^5.0.3",
"svelte": "^4.2.12",
"svelte-check": "^3.6.8",
"svelte-check": "^3.6.9",
"tailwindcss": "^3.4.3",
"tslib": "^2.6.2",
"typescript": "^5.4.3",
"vite": "^5.2.6"
"vite": "^5.2.7"
}
}
Loading

0 comments on commit ad57a5c

Please sign in to comment.