Skip to content
This repository was archived by the owner on Dec 24, 2025. It is now read-only.

Commit df098b7

Browse files
committed
250330 Try to improve workflows
1 parent 40e1125 commit df098b7

File tree

2 files changed

+55
-31
lines changed

2 files changed

+55
-31
lines changed

.github/workflows/first-deployment.yml

Lines changed: 49 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,83 @@
11
name: (Re)initialize Deployment
2+
run-name: (Re)initialize Deployment by ${{ github.actor }}
3+
24
on:
35
workflow_dispatch:
6+
47
env:
58
REPO_NAME: ${{ github.event.repository.name }}
6-
VPS_IP: ${{ secrets.VPS_IP }}
7-
VPS_USER: ${{ secrets.VPS_USER }}
9+
VENV: "venv"
10+
PYTHON: "3.12"
11+
812
jobs:
9-
setup-venv:
13+
clean-up-folder:
1014
runs-on: ubuntu-latest
1115
steps:
12-
- name: Installing venv
16+
- name: Remove Existing Folder
1317
uses: fifsky/ssh-action@master
1418
with:
1519
command: |
16-
rm -rf venv
17-
python3 -m venv venv
18-
cd venv
19-
mkdir ${{ env.REPO_NAME }}
20-
host: ${{ env.VPS_IP }}
21-
user: ${{ env.VPS_USER }}
20+
rm -rf ${{ env.REPO_NAME }} && mkdir ${{ env.REPO_NAME }}
21+
host: ${{ secrets.VPS_IP }}
22+
user: ${{ secrets.VPS_USER }}
23+
key: ${{ secrets.SSH_PRIVATE_KEY }}
24+
args: "-tt"
25+
26+
setup-python:
27+
runs-on: ubuntu-latest
28+
timeout-minutes: 2
29+
steps:
30+
- name: Checkout
31+
uses: actions/checkout@v4
32+
33+
- name: Install pip and venv
34+
uses: fifsky/ssh-action@master
35+
with:
36+
command: |
37+
export DEBIAN_FRONTEND=noninteractive
38+
sudo apt-get install -y python${{env.PYTHON}}-pip python${{env.PYTHON}}-venv
39+
pip --version
40+
41+
host: ${{ secrets.VPS_IP }}
42+
user: ${{ secrets.VPS_USER }}
2243
key: ${{ secrets.SSH_PRIVATE_KEY }}
2344
args: "-tt"
2445

2546
deploy-via-sftp:
26-
needs: [setup-venv]
47+
needs: [ clean-up-folder, setup-python ]
2748
runs-on: ubuntu-latest
2849
steps:
2950
- name: Checkout
30-
uses: actions/checkout@v2
51+
uses: actions/checkout@v4
3152

3253
- name: Deploy to Server
3354
uses: wlixcc/SFTP-Deploy-Action@v1.2.5
3455
with:
35-
username: ${{ env.VPS_USER }}
36-
server: ${{ env.VPS_IP }}
37-
port: 22
56+
username: ${{ secrets.VPS_USER }}
57+
server: ${{ secrets.VPS_IP }}
58+
port: ${{secrets.PORT}}
3859
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}
3960
# clones entire github repo
4061
local_path: ./*
4162
# destination of the code on the server
42-
remote_path: ./venv/${{ env.REPO_NAME }}/
43-
sftpargs: '-o ConnectTimeout=5'
63+
remote_path: ./${{ env.REPO_NAME }}
64+
sftpArgs: '-o ConnectTimeout=15'
4465

45-
install-dependencies:
46-
needs: [deploy-via-sftp]
66+
install-requirements:
67+
needs: [ deploy-via-sftp ]
4768
runs-on: ubuntu-latest
4869
steps:
49-
- name: Installing requirements for ${{ env.REPO_NAME }}
70+
- name: Install Requirements
5071
uses: fifsky/ssh-action@master
5172
with:
52-
# install the libraries required for your bot
53-
# setup venv and then install the requirements
5473
command: |
55-
source venv/bin/activate
74+
cd ${{ env.REPO_NAME }}
75+
python3 -m venv ${{env.VENV}}
76+
source ${{env.VENV}}/bin/activate
5677
pip install --upgrade pip
57-
pip install -U -r ./venv/${{ env.REPO_NAME }}/requirements.txt
58-
host: ${{ env.VPS_IP }}
59-
user: ${{ env.VPS_USER }}
78+
pip install -U -r ./requirements.txt
79+
host: ${{ secrets.VPS_IP }}
80+
user: ${{ secrets.VPS_USER }}
6081
key: ${{ secrets.SSH_PRIVATE_KEY }}
6182
args: "-tt"
6283

@@ -69,7 +90,7 @@ jobs:
6990
uses: fifsky/ssh-action@master
7091
with:
7192
command: |
72-
cd ./venv/${{ env.REPO_NAME }}
93+
cd ${{ env.REPO_NAME }}
7394
echo "DISCORD_API_TOKEN=${{ secrets.DISCORD_API_TOKEN }}" > .env
7495
echo "DISCORD_API_TOKEN_TEST=${{ secrets.DISCORD_API_TOKEN_TEST }}" >> .env
7596
echo "REFER_DB=${{ secrets.REFER_DB }}" >> .env
@@ -89,7 +110,7 @@ jobs:
89110
key: ${{ secrets.SSH_PRIVATE_KEY }}
90111

91112
create-systemctl-service:
92-
needs: [add-secret-variables, install-dependencies]
113+
needs: [add-secret-variables, install-requirements]
93114
runs-on: ubuntu-latest
94115
steps:
95116
- id: creating-systemctl-service

.github/workflows/update-bot.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
name: Update Bot
2+
23
on:
34
push:
45
branches: [ production ]
56
workflow_dispatch:
7+
68
env:
79
REPO_NAME: ${{ github.event.repository.name }}
10+
811
jobs:
912
deploy-via-sftp:
1013
runs-on: ubuntu-latest
@@ -15,11 +18,11 @@ jobs:
1518
with:
1619
username: ${{ secrets.VPS_USER }}
1720
server: ${{ secrets.VPS_IP }}
18-
port: 22
21+
port: ${{ secrets.PORT }}
1922
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}
2023
local_path: ./*
21-
remote_path: ./venv/${{ env.REPO_NAME }}/
22-
sftpargs: '-o ConnectTimeout=5'
24+
remote_path: ./${{ env.REPO_NAME }}/
25+
sftpArgs: '-o ConnectTimeout=15'
2326

2427
restart-bot:
2528
needs: [deploy-via-sftp]

0 commit comments

Comments
 (0)