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

Commit 5685161

Browse files
committed
250330 Remove installing python action
1 parent 0a4e3c9 commit 5685161

File tree

1 file changed

+56
-35
lines changed

1 file changed

+56
-35
lines changed

.github/workflows/first-deployment.yml

Lines changed: 56 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,96 @@
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 }}
2223
key: ${{ secrets.SSH_PRIVATE_KEY }}
2324
args: "-tt"
24-
25-
install-dependencies:
26-
needs: [deploy-via-sftp]
25+
26+
setup-python:
2727
runs-on: ubuntu-latest
28+
timeout-minutes: 2
2829
steps:
29-
- name: Installing requirements for ${{ env.REPO_NAME }}
30+
- name: Checkout
31+
uses: actions/checkout@v4
32+
33+
- name: Install pip and venv
3034
uses: fifsky/ssh-action@master
3135
with:
32-
# install the libraries required for your bot
33-
# setup venv and then install the requirements
3436
command: |
35-
source venv/bin/activate
36-
pip install --upgrade pip
37-
pip install -U -r ./venv/${{ env.REPO_NAME }}/requirements.txt
38-
host: ${{ env.VPS_IP }}
39-
user: ${{ env.VPS_USER }}
37+
export DEBIAN_FRONTEND=noninteractive
38+
sudo apt-get install -y python3-pip python3-venv
39+
pip --version
40+
source ${{env.REPO_NAME}}/source/bin/activate
41+
host: ${{ secrets.VPS_IP }}
42+
user: ${{ secrets.VPS_USER }}
4043
key: ${{ secrets.SSH_PRIVATE_KEY }}
4144
args: "-tt"
42-
45+
4346
deploy-via-sftp:
44-
needs: [setup-venv]
47+
needs: [ clean-up-folder, setup-python ]
4548
runs-on: ubuntu-latest
4649
steps:
4750
- name: Checkout
48-
uses: actions/checkout@v2
49-
51+
uses: actions/checkout@v4
52+
5053
- name: Deploy to Server
5154
uses: wlixcc/SFTP-Deploy-Action@v1.2.5
5255
with:
53-
username: ${{ env.VPS_USER }}
54-
server: ${{ env.VPS_IP }}
55-
port: 22
56+
username: ${{ secrets.VPS_USER }}
57+
server: ${{ secrets.VPS_IP }}
58+
port: ${{secrets.PORT}}
5659
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}
5760
# clones entire github repo
5861
local_path: ./*
5962
# destination of the code on the server
60-
remote_path: ./venv/${{ env.REPO_NAME }}/
61-
sftpargs: '-o ConnectTimeout=5'
62-
63+
remote_path: ./${{ env.REPO_NAME }}
64+
sftpArgs: '-o ConnectTimeout=15'
65+
66+
install-requirements:
67+
needs: [ deploy-via-sftp ]
68+
runs-on: ubuntu-latest
69+
steps:
70+
- name: Install Requirements
71+
uses: fifsky/ssh-action@master
72+
with:
73+
command: |
74+
cd ${{ env.REPO_NAME }}
75+
python3 -m venv ${{env.VENV}}
76+
source ${{env.VENV}}/bin/activate
77+
pip install --upgrade pip
78+
pip install -U -r ./requirements.txt
79+
host: ${{ secrets.VPS_IP }}
80+
user: ${{ secrets.VPS_USER }}
81+
key: ${{ secrets.SSH_PRIVATE_KEY }}
82+
args: "-tt"
83+
6384
add-secret-variables:
64-
needs: [ deploy-via-sftp, install-dependencies ]
85+
needs: [deploy-via-sftp]
6586
runs-on: ubuntu-latest
6687
timeout-minutes: 2
6788
steps:
6889
- id: add-secret-variables
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, deploy-via-sftp]
113+
needs: [add-secret-variables, install-requirements]
93114
runs-on: ubuntu-latest
94115
steps:
95116
- id: creating-systemctl-service
@@ -118,7 +139,7 @@ jobs:
118139
key: ${{ secrets.SSH_PRIVATE_KEY }}
119140

120141
create-systemctl-restart:
121-
needs: [create-systemctl-service, add-secret-variables, deploy-via-sftp]
142+
needs: [create-systemctl-service]
122143
runs-on: ubuntu-latest
123144
steps:
124145
- id: create-systemctl-restart-service

0 commit comments

Comments
 (0)