Man, those click bait titles just keep coming!
We have a faculty member publishing with Quarto and wanted to create a nice little publishing workflow to his Domain of One’s Own account.
Set up your secrets
This is where you set the information that allows you to connect to the server without writing your secrets directly in the action file.
In GitHub, choose one of your repositories
Click on “Settings” from the top horizontal menu.
Click on “Secrets and variables” from the sidebar menu
Choose “Actions” from the options that appear
You will now see the option to create Environment secrets or Repository secrets. If you plan to re-use the same secrets across multiple repositories, choose Environment. If not, set the secrets just to apply to the Repository. Probably, you want to set it at the top level and just use them across all your repos.
For this example, we need three secrets.
- SFTP_USERNAME
- SFTP_PASSWORD
- SFTP_SERVER
Set up the deployment file
In GitHub, choose your repository.
Click on “Actions” from the top horizontal menu
Click “set up a workflow yourself” from the blue text that appears
Paste in the following information and then edit as appropriate. This is a YAML file so it’s picky on spaces and indents.
Make sure your cPanel path is full. So to land in a folder named “target” for an account named “example_account” the path would like this /home/example_account_name/public_html/target/
To copy only a portion of the GitHub repo, something like this would work for the source directory off the root – ./source/
name: Deploy some stuff to a place
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Deploy via SFTP
timeout-minutes: 5
run: |
sudo apt-get install -y lftp
lftp -d -e "
set net:timeout 10;
set net:max-retries 2;
set sftp:connect-program 'ssh -a -x -p 22 -o StrictHostKeyChecking=no -o ConnectTimeout=10';
open sftp://${{ secrets.SFTP_USERNAME }}:${{ secrets.SFTP_PASSWORD }}@${{ secrets.SFTP_SERVER }};
mirror -R ./source/ /home/example_account/public_html/target/;
quit"