Skip to content

Commit ce41174

Browse files
author
niuweili
committed
update manual deploy
1 parent 8471645 commit ce41174

2 files changed

Lines changed: 51 additions & 46 deletions

File tree

.github/workflows/deploy-auto.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ jobs:
8989
"msgtype": "markdown",
9090
"markdown": {
9191
"title": "RUM sdk 部署通知",
92-
"text": "### ✅ RUM sdk 部署成功\n\n---\n\n 🔖 分支: ${{ github.ref }}\n 📝 提交信息: [${{ github.event.head_commit.message }}](https://github.com/${{ github.repository }}/commit/${{ github.sha }})\n 👨‍💻 提交者: ${{ github.actor }}\n 🚀 [查看部署详情](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})"
92+
"text": "### ✅ RUM sdk 部署成功\n\n---\n\n 🔖 分支: ${{ github.ref }}\n\n 📝 提交信息: [${{ github.event.head_commit.message }}](https://github.com/${{ github.repository }}/commit/${{ github.sha }})\n\n 👨‍💻 提交者: ${{ github.actor }}\n\n 🚀 [查看部署详情](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})"
9393
}
9494
}
9595
@@ -117,6 +117,6 @@ jobs:
117117
"msgtype": "markdown",
118118
"markdown": {
119119
"title": "RUM sdk 部署通知",
120-
"text": "### ❌ RUM sdk 部署失败 \n\n---\n\n 🔖 分支: ${{ github.ref }}\n 📝 提交信息: [${{ github.event.head_commit.message }}](https://github.com/${{ github.repository }}/commit/${{ github.sha }})\n 👨‍💻 提交者: ${{ github.actor }}\n 🚀 [查看部署详情](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})"
120+
"text": "### ❌ RUM sdk 部署失败 \n\n---\n\n 🔖 分支: ${{ github.ref }}\n\n 📝 提交信息: [${{ github.event.head_commit.message }}](https://github.com/${{ github.repository }}/commit/${{ github.sha }})\n\n 👨‍💻 提交者: ${{ github.actor }}\n\n 🚀 [查看部署详情](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})"
121121
}
122122
}

.github/workflows/deploy-manual.yml

Lines changed: 49 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ on:
99
default: 'no'
1010

1111
jobs:
12-
pre-notify:
12+
deploy-prod:
1313
runs-on: ubuntu-latest
14-
if: ${{ github.event.inputs.confirm_deploy == 'yes' }}
1514
steps:
1615
- name: Checkout code
1716
uses: actions/checkout@v4
@@ -21,26 +20,35 @@ jobs:
2120
with:
2221
node-version: '18'
2322

24-
- name: Prepare notification
23+
- name: Install dependencies
24+
run: yarn
25+
26+
- name: Export BUILD_MODE
27+
run: export BUILD_MODE=release
28+
29+
- name: Get version
2530
run: |
26-
COMMIT_MESSAGE=$(git show-branch --no-name HEAD)
27-
echo "COMMIT_MESSAGE=$COMMIT_MESSAGE" >> $GITHUB_ENV
28-
echo "BUILD_URL=https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" >> $GITHUB_ENV
29-
echo "COMMIT_URL=https://github.com/${{ github.repository }}/commit/${{ github.sha }}" >> $GITHUB_ENV
31+
FULL_VERSION=$(node -p -e "require('./lerna.json').version")
32+
MAJOR_VERSION=$(echo $FULL_VERSION | cut -d. -f1)
33+
echo "VERSION=$MAJOR_VERSION" >> $GITHUB_ENV
34+
echo "version=$MAJOR_VERSION" >> $GITHUB_OUTPUT
35+
env:
36+
BUILD_MODE: release
3037

31-
- name: Notify deployment ready
32-
if: success()
33-
uses: slackapi/slack-github-action@v1.25.0
34-
with:
35-
channel-id: 'browser-sdk-deploy'
36-
payload: |
37-
{
38-
"text": ":i: ${{ github.repository }} <${{ env.BUILD_URL }}|${{ env.COMMIT_MESSAGE }}> ready to be deployed *manually* to :datadog:"
39-
}
38+
- name: Build bundle
39+
run: yarn build:bundle
40+
41+
- name: Deploy to prod
42+
run: node ./scripts/deploy/deploy-oss.js prod v${VERSION}
4043
env:
41-
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
44+
OSS_ENDPOINT: ${{ secrets.OSS_ENDPOINT }}
45+
OSS_REGION: ${{ secrets.OSS_REGION }}
46+
OSS_ACCESS_KEY: ${{ secrets.OSS_ACCESS_KEY }}
47+
OSS_BUCKET: ${{ secrets.OSS_BUCKET }}
48+
OSS_SECRET_KEY: ${{ secrets.OSS_SECRET_KEY }}
4249

4350
publish-npm:
51+
needs: deploy-prod
4452
runs-on: ubuntu-latest
4553
steps:
4654
- name: Checkout code
@@ -58,9 +66,10 @@ jobs:
5866
- name: Publish to NPM
5967
run: node ./scripts/deploy/publish-npm.js
6068
env:
61-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
62-
63-
post-notify-success:
69+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
70+
71+
notify-success:
72+
needs: publish-npm
6473
runs-on: ubuntu-latest
6574
if: success()
6675
steps:
@@ -74,28 +83,21 @@ jobs:
7483
echo "COMMIT_URL=https://github.com/${{ github.repository }}/commit/${{ github.sha }}" >> $GITHUB_ENV
7584
7685
- name: Notify deployment success
77-
uses: slackapi/slack-github-action@v1.25.0
86+
uses: zcong1993/actions-ding@master
7887
with:
79-
channel-id: 'browser-sdk-deploy'
80-
payload: |
88+
dingToken: ${{ secrets.DING_TALK_TOKEN }}
89+
secret: ${{ secrets.DING_TALK_SECRET }}
90+
body: |
8191
{
82-
"text": ":rocket: ${{ github.repository }} <${{ env.COMMIT_URL }}|${{ env.COMMIT_MESSAGE }}> *manually* deployed to :earth_americas:."
92+
"msgtype": "markdown",
93+
"markdown": {
94+
"title": "RUM sdk 部署通知",
95+
"text": "### ✅ RUM sdk 部署成功\n\n---\n\n 🔖 分支: ${{ github.ref }}\n\n 📝 提交信息: [${{ github.event.head_commit.message }}](https://github.com/${{ github.repository }}/commit/${{ github.sha }})\n\n 👨‍💻 提交者: ${{ github.actor }}\n\n 🚀 [查看部署详情](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})"
96+
}
8397
}
84-
env:
85-
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
8698
87-
- name: Notify ops team
88-
uses: slackapi/slack-github-action@v1.25.0
89-
with:
90-
channel-id: 'rum-browser-sdk-ops'
91-
payload: |
92-
{
93-
"text": ":rocket: ${{ github.repository }} <${{ env.COMMIT_URL }}|${{ env.COMMIT_MESSAGE }}> *manually* deployed to :earth_americas:."
94-
}
95-
env:
96-
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
97-
98-
post-notify-failure:
99+
notify-failure:
100+
needs: publish-npm
99101
runs-on: ubuntu-latest
100102
if: failure()
101103
steps:
@@ -109,12 +111,15 @@ jobs:
109111
echo "BUILD_URL=https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" >> $GITHUB_ENV
110112
111113
- name: Notify deployment failure
112-
uses: slackapi/slack-github-action@v1.25.0
114+
uses: zcong1993/actions-ding@master
113115
with:
114-
channel-id: 'browser-sdk-deploy'
115-
payload: |
116+
dingToken: ${{ secrets.DING_TALK_TOKEN }}
117+
secret: ${{ secrets.DING_TALK_SECRET }}
118+
body: |
116119
{
117-
"text": ":host-red: ${{ github.repository }} *manual* deployment of <${{ env.BUILD_URL }}|${{ env.COMMIT_MESSAGE }}> failed."
120+
"msgtype": "markdown",
121+
"markdown": {
122+
"title": "RUM sdk 部署通知",
123+
"text": "### ❌ RUM sdk 部署失败 \n\n---\n\n 🔖 分支: ${{ github.ref }}\n\n 📝 提交信息: [${{ github.event.head_commit.message }}](https://github.com/${{ github.repository }}/commit/${{ github.sha }})\n\n 👨‍💻 提交者: ${{ github.actor }}\n\n 🚀 [查看部署详情](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})"
124+
}
118125
}
119-
env:
120-
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}

0 commit comments

Comments
 (0)