Skip to content

Commit 74a55bf

Browse files
authored
Make SSH host configurable (default: ssh.pythonanywhere.com) (#1)
1 parent fbb6da7 commit 74a55bf

File tree

4 files changed

+27
-19
lines changed

4 files changed

+27
-19
lines changed

.github/workflows/example.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
name: Deploy to PythonAnywhere
32

43
on:
@@ -12,10 +11,11 @@ jobs:
1211
uses: actions/checkout@v4
1312

1413
- name: Redeploy to PythonAnywhere
15-
uses: MiguelRizzi/pythonanywhere-deploy-ssh@v1
14+
uses: MiguelRizzi/pythonanywhere-deploy-ssh@v1.0.0
1615
with:
17-
username: ${{ secrets.PA_USERNAME }}
18-
password: ${{ secrets.PA_PASSWORD }}
19-
working_directory: ${{ secrets.PA_WORKING_DIRECTORY }}
20-
venv_directory: ${{ secrets.PA_VENV_DIRECTORY }}
21-
wsgi_file: /var/www/webapp_name_wsgi.py
16+
ssh_host: ssh.eu.pythonanywhere.com # Optional - defaults to ssh.pythonanywhere.com
17+
username: ${{ secrets.PA_USERNAME }} # Your PythonAnywhere username
18+
password: ${{ secrets.PA_PASSWORD }} # Your PythonAnywhere password
19+
working_directory: ${{ secrets.PA_WORKING_DIRECTORY }} # Target working directory on PythonAnywhere
20+
venv_directory: ${{ secrets.PA_VENV_DIRECTORY }} # Path to your virtual environment
21+
wsgi_file: /var/www/webapp_name_wsgi.py # Path to your WSGI file

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ jobs:
3434
uses: actions/checkout@v4
3535

3636
- name: Redeploy to PythonAnywhere
37-
uses: MiguelRizzi/pythonanywhere-deploy-ssh@v1
37+
uses: MiguelRizzi/pythonanywhere-deploy-ssh@v1.0.0
3838
with:
39+
ssh_host: ssh.eu.pythonanywhere.com # Optional - defaults to ssh.pythonanywhere.com
3940
username: ${{ secrets.PA_USERNAME }}
4041
password: ${{ secrets.PA_PASSWORD }}
4142
working_directory: ${{ secrets.PA_WORKING_DIRECTORY }}
@@ -47,11 +48,12 @@ jobs:
4748
4849
| Name | Description | Required | Example |
4950
|-----------|-------------|----------|---------|
50-
| username | Your PythonAnywhere username | ✅ | miguelrizzi |
51-
| password | Your PythonAnywhere password | ✅ | password |
52-
| working_directory | Target working directory on PythonAnywhere | ✅ | /home/username/webapp_name |
53-
| venv_directory | Path to the Python virtual environment | ✅ | /home/username/webapp_name/.venv |
54-
| wsgi_file | Path to the WSGI file to reload the app | ✅ | /var/www/webapp_name_wsgi.py |
51+
| ssh_host | Optional SSH host for PythonAnywhere (default: ssh.pythonanywhere.com) | No | ssh.eu.pythonanywhere.com |
52+
| username | Your PythonAnywhere username | Yes | miguelrizzi |
53+
| password | Your PythonAnywhere password | Yes | password |
54+
| working_directory | Target working directory on PythonAnywhere | Yes | /home/username/webapp_name |
55+
| venv_directory | Path to the Python virtual environment | Yes | /home/username/webapp_name/.venv |
56+
| wsgi_file | Path to the WSGI file to reload the app | Yes | /var/www/webapp_name_wsgi.py |
5557
5658
5759
## 🔐 Security

action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ branding:
77
color: blue
88

99
inputs:
10+
ssh_host:
11+
description: "SSH host for PythonAnywhere (default: ssh.pythonanywhere.com)"
12+
required: false
13+
default: "ssh.pythonanywhere.com"
1014
username:
1115
description: "Your PythonAnywhere username"
1216
required: true
@@ -27,6 +31,7 @@ runs:
2731
using: docker
2832
image: Dockerfile
2933
args:
34+
- ${{ inputs.ssh_host }}
3035
- ${{ inputs.username }}
3136
- ${{ inputs.password }}
3237
- ${{ inputs.working_directory }}

deploy.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
#!/bin/bash
22
set -e
33

4-
USERNAME=$1
5-
PASSWORD=$2
6-
WORKING_DIRECTORY=$3
7-
VENV_DIRECTORY=$4
8-
WSGI_FILE=$5
4+
SSH_HOST=$1
5+
USERNAME=$2
6+
PASSWORD=$3
7+
WORKING_DIRECTORY=$4
8+
VENV_DIRECTORY=$5
9+
WSGI_FILE=$6
910

1011
echo "Connecting to PythonAnywhere server..."
1112

12-
sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no "$USERNAME@ssh.pythonanywhere.com" << EOF
13+
sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no "$USERNAME@$SSH_HOST" << EOF
1314
echo "Changing to working directory..."
1415
cd "$WORKING_DIRECTORY"
1516
echo "Activating virtual environment..."

0 commit comments

Comments
 (0)