Skip to content

Commit

Permalink
👷 新增部署到服务器CI
Browse files Browse the repository at this point in the history
  • Loading branch information
pecasha committed Apr 3, 2024
1 parent ad57a5c commit c607643
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 3 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/deploy-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Deploy Prod to Tencent Cloud
on: workflow_dispatch
jobs:
deploy:
runs-on: ubuntu-latest
env:
NPM_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v3
with:
version: "latest"
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: "20.x"
cache: "pnpm"
cache-dependency-path: "pnpm-lock.yaml"
- name: Install Dependencies
run: pnpm i
- name: Build
run: |
pnpm check
pnpm build
- name: Deploy to Server
uses: easingthemes/ssh-deploy@main
with:
SSH_PRIVATE_KEY: ${{ secrets.TENCENT_CLOUD_SSH_PRIVATE_KEY }}
REMOTE_HOST: ${{ secrets.TENCENT_CLOUD_REMOTE_HOST }}
REMOTE_USER: ${{ secrets.TENCENT_CLOUD_REMOTE_USER }}
TARGET: ${{ secrets.TENCENT_CLOUD_DEPLOY_TARGET }}
SOURCE: "build/"
ARGS: "-avzr --delete"
- name: Pack Artifacts
uses: actions/upload-artifact@v4
with:
name: build-${{ github.run_id }}
path: build
dispatch:
needs: deploy
runs-on: ubuntu-latest
env:
SECRET_ID: ${{ secrets.TENCENT_CLOUD_SECRET_ID }}
SECRET_KEY: ${{ secrets.TENCENT_CLOUD_SECRET_KEY }}
steps:
- name: pip Cache
uses: actions/cache@v4
id: cache
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-deploy-prod
- name: Install tccli
run: pip install tccli
- name: Authenticate With Tencent Cloud CLI
run: tccli configure set secretId $SECRET_ID secretKey $SECRET_KEY
- name: Purge Tencent Cloud CDN Cache
run: tccli cdn PurgeUrlsCache --Urls "$(echo '["${{ vars.WEBSITE_DOMAIN }}"]')"
10 changes: 8 additions & 2 deletions .github/workflows/images-cdn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,14 @@ jobs:
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: pip Cache
uses: actions/cache@v4
id: cache
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-images-cdn
- name: Install coscmd
run: sudo pip install coscmd
run: 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
Expand All @@ -42,7 +48,7 @@ jobs:
coscmd upload $file $COS_PATH
done
- name: Install tccli
run: sudo pip install tccli
run: pip install tccli
- name: Authenticate With Tencent Cloud CLI
run: tccli configure set secretId $SECRET_ID secretKey $SECRET_KEY
- name: Split Urls
Expand Down
3 changes: 2 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//npm.pkg.github.com/:_authToken=${NPM_AUTH_TOKEN}
@pecasha:registry=https://npm.pkg.github.com
engine-strict=true
resolution-mode=highest
auto-install-peers=true
shamefully-hoist=true
@pecasha:registry=https://npm.pkg.github.com

0 comments on commit c607643

Please sign in to comment.