Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/workflows/example.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

name: Deploy to PythonAnywhere

on:
Expand All @@ -12,10 +11,11 @@ jobs:
uses: actions/checkout@v4

- name: Redeploy to PythonAnywhere
uses: MiguelRizzi/pythonanywhere-deploy-ssh@v1
uses: MiguelRizzi/pythonanywhere-deploy-ssh@v1.0.0
with:
username: ${{ secrets.PA_USERNAME }}
password: ${{ secrets.PA_PASSWORD }}
working_directory: ${{ secrets.PA_WORKING_DIRECTORY }}
venv_directory: ${{ secrets.PA_VENV_DIRECTORY }}
wsgi_file: /var/www/webapp_name_wsgi.py
ssh_host: ssh.eu.pythonanywhere.com # Optional - defaults to ssh.pythonanywhere.com
username: ${{ secrets.PA_USERNAME }} # Your PythonAnywhere username
password: ${{ secrets.PA_PASSWORD }} # Your PythonAnywhere password
working_directory: ${{ secrets.PA_WORKING_DIRECTORY }} # Target working directory on PythonAnywhere
venv_directory: ${{ secrets.PA_VENV_DIRECTORY }} # Path to your virtual environment
wsgi_file: /var/www/webapp_name_wsgi.py # Path to your WSGI file
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ jobs:
uses: actions/checkout@v4

- name: Redeploy to PythonAnywhere
uses: MiguelRizzi/pythonanywhere-deploy-ssh@v1
uses: MiguelRizzi/pythonanywhere-deploy-ssh@v1.0.0
with:
ssh_host: ssh.eu.pythonanywhere.com # Optional - defaults to ssh.pythonanywhere.com
username: ${{ secrets.PA_USERNAME }}
password: ${{ secrets.PA_PASSWORD }}
working_directory: ${{ secrets.PA_WORKING_DIRECTORY }}
Expand All @@ -47,11 +48,12 @@ jobs:

| Name | Description | Required | Example |
|-----------|-------------|----------|---------|
| username | Your PythonAnywhere username | ✅ | miguelrizzi |
| password | Your PythonAnywhere password | ✅ | password |
| working_directory | Target working directory on PythonAnywhere | ✅ | /home/username/webapp_name |
| venv_directory | Path to the Python virtual environment | ✅ | /home/username/webapp_name/.venv |
| wsgi_file | Path to the WSGI file to reload the app | ✅ | /var/www/webapp_name_wsgi.py |
| ssh_host | Optional SSH host for PythonAnywhere (default: ssh.pythonanywhere.com) | No | ssh.eu.pythonanywhere.com |
| username | Your PythonAnywhere username | Yes | miguelrizzi |
| password | Your PythonAnywhere password | Yes | password |
| working_directory | Target working directory on PythonAnywhere | Yes | /home/username/webapp_name |
| venv_directory | Path to the Python virtual environment | Yes | /home/username/webapp_name/.venv |
| wsgi_file | Path to the WSGI file to reload the app | Yes | /var/www/webapp_name_wsgi.py |


## 🔐 Security
Expand Down
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ branding:
color: blue

inputs:
ssh_host:
description: "SSH host for PythonAnywhere (default: ssh.pythonanywhere.com)"
required: false
default: "ssh.pythonanywhere.com"
username:
description: "Your PythonAnywhere username"
required: true
Expand All @@ -27,6 +31,7 @@ runs:
using: docker
image: Dockerfile
args:
- ${{ inputs.ssh_host }}
- ${{ inputs.username }}
- ${{ inputs.password }}
- ${{ inputs.working_directory }}
Expand Down
13 changes: 7 additions & 6 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
#!/bin/bash
set -e

USERNAME=$1
PASSWORD=$2
WORKING_DIRECTORY=$3
VENV_DIRECTORY=$4
WSGI_FILE=$5
SSH_HOST=$1
USERNAME=$2
PASSWORD=$3
WORKING_DIRECTORY=$4
VENV_DIRECTORY=$5
WSGI_FILE=$6

echo "Connecting to PythonAnywhere server..."

sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no "$USERNAME@ssh.pythonanywhere.com" << EOF
sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no "$USERNAME@$SSH_HOST" << EOF
echo "Changing to working directory..."
cd "$WORKING_DIRECTORY"
echo "Activating virtual environment..."
Expand Down