Skip to content

Commit

Permalink
change build mode
Browse files Browse the repository at this point in the history
  • Loading branch information
arc0035 committed Nov 1, 2023
1 parent 394c575 commit 1926c94
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 23 deletions.
26 changes: 5 additions & 21 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,6 @@ jobs:
steps:
- run: |
echo Build is triggered
- uses: actions/checkout@v2 #拉取项目文件
- name: Set up JDK 8 #配置java环境
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'
cache: 'gradle'
- name: Grant execute permission for gradlew #更改脚本权限
run: chmod +x gradlew
- name: Build with Gradle #开始打包 -x test 跳过测试
run: ./gradlew jar -x test
- name: Copy folder content recursively to remote
uses: garygrossgarten/github-action-scp@release
with:
local: dist
remote: "/root/Dapp-Learning-Official-web/dist"
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
port: ${{ secrets.PORT }} # 服务器ssh端口(默认22)
- name: deploy_app #开始部署
uses: appleboy/ssh-action@master
with:
Expand All @@ -48,9 +28,13 @@ jobs:
password: ${{ secrets.PASSWORD }} #服务器ssh密码
port: ${{ secrets.PORT }} # 服务器ssh端口(默认22)
script: |
cd /root/Dapp-Learning-Official-web/dist
cd /root/Official-website-backend
git pull
bash ./gradlew build -x test
cd dist
export DBPWD=${{secrets.SPRING_DATASOURCE_PASSWORD}}
echo setting DBPWD to $DBPWD
sed "s/\${SPRING_DATASOURCE_PASSWORD}/$DBPWD/g" conf/application.yml > conf/application.yml
bash stop.sh
bash start.sh
56 changes: 56 additions & 0 deletions .github/workflows/main.yml.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Official Backend CICD

on:
push:
# 分支
branches: [ main ]
pull_request_target:
branches: [ main ]
types: [closed]
workflow_dispatch:

jobs:
build:
if: |
github.event.pull_request.merged == true ||
github.event_name == 'push' ||
github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
name: Building background
steps:
- run: |
echo Build is triggered
- uses: actions/checkout@v2 #拉取项目文件
- name: Set up JDK 8 #配置java环境
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'
cache: 'gradle'
- name: Grant execute permission for gradlew #更改脚本权限
run: chmod +x gradlew
- name: Build with Gradle #开始打包 -x test 跳过测试
run: ./gradlew jar -x test
- name: Copy folder content recursively to remote
uses: garygrossgarten/github-action-scp@release
with:
local: dist
remote: "/root/Dapp-Learning-Official-web/dist"
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
port: ${{ secrets.PORT }} # 服务器ssh端口(默认22)
- name: deploy_app #开始部署
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }} #服务器ip地址
username: ${{ secrets.USERNAME }} #服务器ssh用户名
password: ${{ secrets.PASSWORD }} #服务器ssh密码
port: ${{ secrets.PORT }} # 服务器ssh端口(默认22)
script: |
cd /root/Dapp-Learning-Official-web/dist
export DBPWD=${{secrets.SPRING_DATASOURCE_PASSWORD}}
echo setting DBPWD to $DBPWD
sed "s/\${SPRING_DATASOURCE_PASSWORD}/$DBPWD/g" conf/application.yml > conf/application.yml
bash stop.sh
bash start.sh
4 changes: 2 additions & 2 deletions stop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ CURRENT_DIR=$(pwd)/
CONF_DIR=${CURRENT_DIR}conf

SERVER_PORT=$(cat $CONF_DIR/application.yml | grep "server:" -A 3 | grep "port" | awk '{print $2}'| sed 's/\r//')
if [ ${SERVER_PORT}"" = "" ];then
if [ "${SERVER_PORT}" = "" ];then
echo "$CONF_DIR/application.yml server port has not been configured"
exit -1
fi
Expand All @@ -23,7 +23,7 @@ checkProcess(){
stop(){
checkProcess
echo "==============================================================================================="
if [ $processPid -ne 0 ]; then
if [ "$processPid" -ne 0 ]; then
echo -n "Stopping Server $APP_MAIN Port $SERVER_PORT PID($processPid)..."
kill -9 $processPid
if [ $? -eq 0 ]; then
Expand Down

0 comments on commit 1926c94

Please sign in to comment.