Skip to content

Commit f4dfaa8

Browse files
Extract “Publish to COS” into a composite action
1 parent 7926b17 commit f4dfaa8

File tree

2 files changed

+34
-17
lines changed

2 files changed

+34
-17
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Publish to Tencent Cloud COS
2+
description: Publish static files to Tencent Cloud Object Storage
3+
4+
inputs:
5+
secret_id:
6+
description: Tencent Cloud Secret ID
7+
required: true
8+
secret_key:
9+
description: Tencent Cloud Secret Key
10+
required: true
11+
12+
runs:
13+
using: composite
14+
steps:
15+
- name: Setup Python
16+
uses: actions/setup-python@v5
17+
with:
18+
python-version: '3.11'
19+
20+
- name: Install coscmd
21+
run: pip install coscmd
22+
shell: bash
23+
24+
- name: Configure coscmd
25+
run: coscmd config -a ${{ inputs.secret_id }} -s ${{ inputs.secret_key }} -b nk2028-1305783649 -r ap-guangzhou
26+
shell: bash
27+
28+
- name: Publish static files to COS
29+
run: coscmd upload -rs --delete -f . /tshet-uinh-examples --ignore '*/.*,*/node_modules/*,./test/*,./build/*,./dist/*,./package.json,./package-lock.json,./eslint.config.js'
30+
shell: bash

.github/workflows/build.yml

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,28 +35,15 @@ jobs:
3535
- name: Run tests
3636
run: npm test
3737

38-
# Publish to NPM
3938
- if: github.event_name == 'release'
4039
name: Publish to NPM
4140
run: npm publish
4241
env:
4342
NODE_AUTH_TOKEN: ${{ secrets.npm_token }}
4443

45-
# Publish to Tencent Cloud COS
4644
- if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.repository == 'nk2028/tshet-uinh-examples' && github.ref == 'refs/heads/main')
47-
name: Setup Python
48-
uses: actions/setup-python@v5
45+
name: Publish to Tencent Cloud COS
46+
uses: ./.github/actions/publish-to-cos
4947
with:
50-
python-version: '3.11'
51-
- if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.repository == 'nk2028/tshet-uinh-examples' && github.ref == 'refs/heads/main')
52-
name: Install coscmd
53-
run: pip install coscmd
54-
- if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.repository == 'nk2028/tshet-uinh-examples' && github.ref == 'refs/heads/main')
55-
name: Configure coscmd
56-
env:
57-
SECRET_ID: ${{ secrets.SecretId }}
58-
SECRET_KEY: ${{ secrets.SecretKey }}
59-
run: coscmd config -a $SECRET_ID -s $SECRET_KEY -b nk2028-1305783649 -r ap-guangzhou
60-
- if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.repository == 'nk2028/tshet-uinh-examples' && github.ref == 'refs/heads/main')
61-
name: Publish static files to COS
62-
run: coscmd upload -rs --delete -f . /tshet-uinh-examples --ignore '*/.*,*/node_modules/*,./test/*,./build/*,./dist/*,./package.json,./package-lock.json,./eslint.config.js'
48+
secret_id: ${{ secrets.SecretId }}
49+
secret_key: ${{ secrets.SecretKey }}

0 commit comments

Comments
 (0)