@@ -101,8 +101,8 @@ jobs:
101
101
key : ${{ runner.os }}-submodules-${{ hashFiles('.submodules/**/yarn.lock') }}
102
102
- name : Build
103
103
run : yarn build:clients && yarn build:servers
104
- - name : Show Dir
105
- run : ls
104
+ - name : List dist dir
105
+ run : ls dist
106
106
- name : Build the Docker image
107
107
run :
108
108
| # 使用 上一步写的 Dockerfile 构建镜像并发布到私有仓库; 发布完成可以去 https://github.com/aceHubert?tab=packages 查看
@@ -115,6 +115,8 @@ jobs:
115
115
environment :
116
116
name : ' production'
117
117
steps :
118
+ - name : Checkout repository
119
+ uses : actions/checkout@v3
118
120
- name : Copy docker compose file to server
119
121
120
122
with :
@@ -126,38 +128,37 @@ jobs:
126
128
target : ${{ vars.PROJECT_DIR }} # 服务器文件夹路径
127
129
overwrite : true
128
130
- name : Replace domain in nginx conf file
129
- uses : jacobtomlinson/gha-find-replace@v3
130
- with :
131
- include : " nginx.conf"
132
- find : " example.com"
133
- replace : " ${{ vars.DOMAIN}}"
134
- regex : false
131
+ uses : jacobtomlinson/gha-find-replace@v3
132
+ with :
133
+ include : " nginx.conf"
134
+ find : " example.com"
135
+ replace : " ${{ vars.DOMAIN}}"
136
+ regex : false
135
137
- name : Copy nginx conf file to server
136
-
137
- with :
138
- host : ${{ secrets.HW_SSH_HOST }} # 服务器ip地址 ; 需要去仓库的 settings/secrets/actions 去创建
139
- username : ${{ secrets.HW_SSH_USERNAME }} # 服务器用户名称;需要去仓库的 settings/secrets/actions 去创建
140
- key : ${{ secrets.HW_SSH_KEY }} # 服务器密码;需要去仓库的 settings/secrets/actions 去创建
141
- port : ${{ secrets.HW_SSH_PORT }} # 服务器端口,默认22;需要去仓库的 settings/secrets/actions 去创建
142
- source : " nginx.conf" # 本地文件路径
143
- target : ${{ vars.PROJECT_DIR }} # 服务器文件夹路径
144
- overwrite : true
138
+
139
+ with :
140
+ host : ${{ secrets.HW_SSH_HOST }} # 服务器ip地址 ; 需要去仓库的 settings/secrets/actions 去创建
141
+ username : ${{ secrets.HW_SSH_USERNAME }} # 服务器用户名称;需要去仓库的 settings/secrets/actions 去创建
142
+ key : ${{ secrets.HW_SSH_KEY }} # 服务器密码;需要去仓库的 settings/secrets/actions 去创建
143
+ port : ${{ secrets.HW_SSH_PORT }} # 服务器端口,默认22;需要去仓库的 settings/secrets/actions 去创建
144
+ source : " nginx.conf" # 本地文件路径
145
+ target : ${{ vars.PROJECT_DIR }} # 服务器文件夹路径
146
+ overwrite : true
145
147
- name : Deploy
146
148
147
149
with :
148
150
host : ${{ secrets.HW_SSH_HOST }} # 服务器ip地址 ; 需要去仓库的 settings/secrets/actions 去创建
149
151
username : ${{ secrets.HW_SSH_USERNAME }} # 服务器用户名称;需要去仓库的 settings/secrets/actions 去创建
150
152
key : ${{ secrets.HW_SSH_KEY }} # 服务器密码;需要去仓库的 settings/secrets/actions 去创建
151
153
port : ${{ secrets.HW_SSH_PORT }} # 服务器端口,默认22;需要去仓库的 settings/secrets/actions 去创建
152
- debug : true
153
- command_timeout : 60m
154
154
script : | # 发布镜像并删除之前的镜像
155
155
whoami
156
156
cd ${{ vars.PROJECT_DIR }}
157
+ echo "IMAGE_REPOSITORY=${{ env.REGISTRY_MIRROR }}/${{ env.IMAGE_REPOSITORY }}:${{ github.run_id }}" > .env.${{ github.run_id }}
158
+ echo -e "ORIGIN=https://${{vars.DOMAIN}}\nREDIS_URL=${{secrets.REDIS_URL}}\nINFRASTRUCTURE_DATABASE_CONNECTION=${{secrets.INFRASTRUCTURE_DATABASE_CONNECTION}}\nIDENTITY_DATABASE_CONNECTION=${{secrets.IDENTITY_DATABASE_CONNECTION}}" >> .env.${{ github.run_id }}
157
159
mv docker-compose.deploy.yml docker-compose.yml
158
- echo "IMAGE_REPOSITORY=${{ env.REGISTRY_MIRROR }}/${{ env.IMAGE_REPOSITORY }}:${{ github.run_id }}\nORIGIN=https://${{vars.DOMAIN}}\nREDIS_URL=${{secret.REDIS_URL}}\nINFRASTRUCTURE_DATABASE_CONNECTION=${{secrets.INFRASTRUCTURE_DATABASE_CONNECTION}}\nIDENTITY_DATABASE_CONNECTION=${{secrets.IDENTITY_DATABASE_CONNECTION}}" > .env.${{ github.run_id }}
159
160
docker compose --env-file .env.${{ github.run_id }} up --force-recreate -d
160
161
docker images -q ${{ env.REGISTRY_MIRROR }}/${{ env.IMAGE_REPOSITORY }} | grep -v $(docker images -q ${{ env.REGISTRY_MIRROR }}/${{ env.IMAGE_REPOSITORY }}:${{ github.run_id }}) | xargs --no-run-if-empty docker rmi
161
162
rm -f .env.${{ github.run_id }}
162
- mv nginx.conf ${{ vars.NGINX_CONF_DIR }}/pomelo.conf
163
+ mv nginx.conf ${{ vars.HW_NGINX_CONF_DIR }}/pomelo.conf
163
164
/etc/init.d/nginx reload
0 commit comments