-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
👷 新增邮票图片自动上传COS操作,用于本地开发时直接使用仓库中的图片,推送代码到仓库时检测变更的图片自动上传至COS
- Loading branch information
Showing
79 changed files
with
194 additions
and
110 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }}')" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,5 +19,3 @@ vite.config.ts.timestamp-* | |
*.sw? | ||
|
||
*.tsbuildinfo | ||
|
||
.env.development |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.