Skip to content
This repository was archived by the owner on Jun 25, 2024. It is now read-only.

Commit b50b4f2

Browse files
authored
Create main.yml
1 parent 56e2797 commit b50b4f2

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

.github/workflows/main.yml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Deploy to server
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
build:
10+
name: Build and Deploy
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Executing remote ssh commands using ssh key
14+
uses: appleboy/ssh-action@master
15+
with:
16+
host: ${{ secrets.HOST }}
17+
username: ${{ secrets.USERNAME }}
18+
key: ${{ secrets.KEY }}
19+
port: ${{ secrets.PORT }}
20+
script: |
21+
cd repos/AIKyaru
22+
git pull origin master
23+
COMMIT_ID=${{ github.sha }}
24+
docker build -t aikyaru .
25+
CONTAINER_ID=$(docker ps -a --format "table {{.ID}} {{.Names}}" -f "status=running" | awk 'NR>1 && $2 ~ /^aikyaru/ {print$1}')
26+
[[ ! -z "$CONTAINER_ID" ]] && docker stop $CONTAINER_ID
27+
docker run -d \
28+
--name aikyaru_${COMMIT_ID:0:7} \
29+
-e BOT_TOKEN=${{ secrets.BOT_TOKEN }} \
30+
-v ${{ secrets.CONFIG_PATH }}/config.json:/app/config.json \
31+
-v ${{ secrets.CONFIG_PATH }}/gameDB:/app/gameDB \
32+
--restart unless-stopped \
33+
--network mongo-network \
34+
aikyaru
35+
36+
- name: Send message to Discord
37+
uses: sarisia/actions-status-discord@v1
38+
with:
39+
webhook: ${{ secrets.DISCORD_WEBHOOK }}
40+
title: "deploy"
41+
color: 0x4BB543

0 commit comments

Comments
 (0)