diff --git a/.github/actions/publish-to-cos/action.yml b/.github/actions/publish-to-cos/action.yml new file mode 100644 index 0000000..3a59a68 --- /dev/null +++ b/.github/actions/publish-to-cos/action.yml @@ -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 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index abd9478..96e2624 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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'