Skip to content

Commit

Permalink
Extract “Publish to COS” into a composite action
Browse files Browse the repository at this point in the history
  • Loading branch information
graphemecluster committed Jan 8, 2025
1 parent 7926b17 commit 529a3f4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
22 changes: 22 additions & 0 deletions .github/actions/publish-to-cos/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Publish to Tencent Cloud COS
description: Publish static files to Tencent Cloud Object Storage

runs:
using: composite
steps:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install coscmd
run: pip install coscmd
shell: bash

- name: Configure coscmd
run: coscmd config -a $SECRET_ID -s $SECRET_KEY -b nk2028-1305783649 -r ap-guangzhou
shell: bash

- name: Publish static files to COS
run: coscmd upload -rs --delete -f . /tshet-uinh-examples --ignore '*/.*,*/node_modules/*,./test/*,./build/*,./dist/*,./package.json,./package-lock.json,./eslint.config.js'
shell: bash
17 changes: 2 additions & 15 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,28 +35,15 @@ jobs:
- name: Run tests
run: npm test

# Publish to NPM
- if: github.event_name == 'release'
name: Publish to NPM
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.npm_token }}

# Publish to Tencent Cloud COS
- if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.repository == 'nk2028/tshet-uinh-examples' && github.ref == 'refs/heads/main')
name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.repository == 'nk2028/tshet-uinh-examples' && github.ref == 'refs/heads/main')
name: Install coscmd
run: pip install coscmd
- if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.repository == 'nk2028/tshet-uinh-examples' && github.ref == 'refs/heads/main')
name: Configure coscmd
name: Publish to Tencent Cloud COS
uses: ./.github/actions/publish-to-cos
env:
SECRET_ID: ${{ secrets.SecretId }}
SECRET_KEY: ${{ secrets.SecretKey }}
run: coscmd config -a $SECRET_ID -s $SECRET_KEY -b nk2028-1305783649 -r ap-guangzhou
- if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.repository == 'nk2028/tshet-uinh-examples' && github.ref == 'refs/heads/main')
name: Publish static files to COS
run: coscmd upload -rs --delete -f . /tshet-uinh-examples --ignore '*/.*,*/node_modules/*,./test/*,./build/*,./dist/*,./package.json,./package-lock.json,./eslint.config.js'

0 comments on commit 529a3f4

Please sign in to comment.