-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
yanfeng.guan
committed
May 14, 2024
1 parent
b2e50bc
commit 14869ca
Showing
6 changed files
with
75 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name: learn-github-actions | ||
run-name: ${{ github.actor }} is learning GitHub Actions | ||
on: [push] | ||
jobs: | ||
check-bats-version: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20' | ||
- run: npm install -g bats | ||
- run: bats -v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,49 @@ | ||
|
||
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions | ||
# github actions 中文文档 https://docs.github.com/cn/actions/getting-started-with-github-actions | ||
|
||
name: deploy for dev | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'dev' # 只针对 dev 分支 | ||
paths: | ||
- '.github/workflows/*' | ||
# - '__test__/**' # dev 不需要立即测试 | ||
- 'src/**' | ||
- 'Dockerfile' | ||
- 'docker-compose.yml' | ||
- 'bin/*' | ||
|
||
jobs: | ||
deploy-dev: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: set ssh key # 临时设置 ssh key | ||
run: | | ||
mkdir -p ~/.ssh/ | ||
echo "${{secrets.WFP_ID_RSA}}" > ~/.ssh/id_rsa # secret 在这里配置 https://github.com/imooc-lego/biz-editor-server/settings/secrets | ||
chmod 600 ~/.ssh/id_rsa | ||
ssh-keyscan "182.92.xxx.xxx" >> ~/.ssh/known_hosts | ||
- name: deploy # 部署 | ||
run: | | ||
ssh [email protected] " | ||
# 【注意】用 work 账号登录,手动创建 /home/work/imooc-lego 目录 | ||
# 然后 git clone https://username:[email protected]/imooc-lego/biz-editor-server.git -b dev (私有仓库,使用 github 用户名和密码) | ||
# 记得删除 origin ,否则会暴露 github 密码 | ||
cd /home/work/imooc-lego/biz-editor-server; | ||
git remote add origin https://wangfupeng1988:${{secrets.WFP_PASSWORD}}@github.com/imooc-lego/biz-editor-server.git; | ||
git checkout dev; | ||
git pull origin dev; # 重新下载最新代码 | ||
git remote remove origin; # 删除 origin ,否则会暴露 github 密码 | ||
# 启动 docker | ||
docker-compose build editor-server; # 和 docker-compose.yml service 名字一致 | ||
docker-compose up -d; | ||
" | ||
- name: delete ssh key # 删除 ssh key | ||
run: rm -rf ~/.ssh/id_rsa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters