generated from XNXKTech/koa-template
-
Notifications
You must be signed in to change notification settings - Fork 0
113 lines (102 loc) · 3.61 KB
/
serverless.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
name: 'Deploy Serverless'
on: # rebuild any PRs and main branch changes
push:
branches:
- main
paths:
- 'dist/index.js'
workflow_dispatch:
inputs:
version:
required: false
description: 'Version (eg. v2.5.0)'
default: latest
jobs:
deploy:
runs-on: ubuntu-latest
strategy:
matrix:
node: [ '12.16' ]
name: Deploy Serverless to Tencent
steps:
- name: Checkout Latest Stable Version
if: ${{ github.event.inputs.version }} == 'latest'
uses: actions/checkout@v3
- name: Checkout ${{ github.event.inputs.version }}
if: github.event.inputs.version != 'latest'
uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.version }}
- name: Setup Node ${{ matrix.node }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: Get yarn cache
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v3
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- run: rm -f .yarnclean
- name: Install dependencies
run: yarn --frozen-lockfile
env:
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
HUSKY_SKIP_INSTALL: true
- run: yarn build
- name: Setup Serverless
uses: teakowa/setup-serverless@v2
with:
provider: tencent
env:
TENCENT_APPID: ${{ secrets.TENCENTCLOUD_APP_ID }}
TENCENT_SECRET_ID: ${{ secrets.TENCENTCLOUD_SECRET_ID }}
TENCENT_SECRET_KEY: ${{ secrets.TENCENTCLOUD_SECRET_KEY}}
SERVERLESS_PLATFORM_VENDOR: tencent
- name: Deploy Serverless
run: sls deploy
- name: Slack Notification
if: success()
uses: tokorom/action-slack-incoming-webhook@v1.3.0
env:
INCOMING_WEBHOOK_URL: ${{ secrets.CI_DEPLOY_WEBHOOK }}
with:
text: Successful deploy of ${{ github.repository}}
attachments: |
[
{
"color": "good",
"author_name": "${{ github.actor }}",
"author_icon": "${{ github.event.sender.avatar_url }}",
"title": "${{ github.event.head_commit.message }}",
"title_link": "${{ github.event.repository.url }}/commit/${{ github.sha }}",
"text": "查看 Workflow <${{ github.event.repository.url }}/actions/runs/${{ github.run_id }}|构建日志>",
"fields": [
{
"title": "Compare URL",
"value": "${{ github.event.compare }}"
}
]
}
]
- name: Slack Notification
if: failure()
uses: tokorom/action-slack-incoming-webhook@v1.3.0
env:
INCOMING_WEBHOOK_URL: ${{ secrets.CI_DEPLOY_WEBHOOK }}
with:
text: Failures deploy of ${{ github.repository}}
attachments: |
[
{
"color": "danger",
"author_name": "${{ github.actor }}",
"author_icon": "${{ github.event.sender.avatar_url }}",
"title": "${{ github.event.head_commit.message }}",
"title_link": "${{ github.event.repository.url }}/commit/${{ github.sha }}",
"text": "查看 Workflow <${{ github.event.repository.url }}/actions/runs/${{ github.run_id }}|构建日志>",
}
]