-
Notifications
You must be signed in to change notification settings - Fork 0
64 lines (64 loc) · 2.46 KB
/
deploy-prod.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
name: Deploy Prod to Tencent Cloud
on:
push:
branches:
- main
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && contains(github.event.head_commit.message, '[deploy]'))
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: "22.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.DEPLOY_CDN_PURGE_URLS }}')"