Warning: This only works if you enable Password authentication in Digital Ocean.
If you want to use Key authentication, most tutorials in Google already cover that.
In your repo, create .github/workflow/deploy.yml
containing this:
name: Deploy via SSH
on: push
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Deploy app
uses: appleboy/ssh-action@v0.1.4
with:
host: 123.45.67.89
username: ${{ secrets.DO_USERNAME }}
password: ${{ secrets.DO_PASSWORD }}
script: |
cd ~/var/www
git clone https://${{ secrets.ACCESS_TOKEN }}:x-oauth-basic@github.com/USERNAME/REPO_NAME.git
echo "Deployment successful to Digital Ocean"
Don't forget to change the target directory (the one you cd
into), host IP Address, and github link.
In your repo, click "Settings" tab then choose "Secrets" from sidebar.
Enter in these 3 credentials:
- DO_USERNAME - your Digital Ocean's username
- DO_PASSWORD - your Digital Ocean's password
- ACCESS_TOKEN - your Github's access token. Generate it from here https://github.com/settings/tokens
Push something and see the log in "Actions" tab. A common error is your user has no permission in the specified directory.
Done!
hey @hrsetyono thanks!
Would like to know if this is possible?
I'd like to deploy two websites from single github private repo.
One website is the
admin panel
and another website is themain
application.Both are subfolders inside the repo
Is it possible to deploy two websites from a single github private repository?