Skip to content

Commit

Permalink
Update ssh login method dev.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob-in-son authored Aug 9, 2024
1 parent ee1056f commit 5b19914
Showing 1 changed file with 34 additions and 33 deletions.
67 changes: 34 additions & 33 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,38 @@ on:
jobs:
build-and-deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Build Docker image
run: |
docker build -t backend_dev .
- name: Save Docker image to tarball
run: |
docker save backend_dev | gzip > backend_dev.tar.gz
- name: Upload to server
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
port: ${{ secrets.PORT }}
script: scp backend_dev.tar.gz $USERNAME@$HOST:/opt/backend-tar/

- name: Load Docker image on server and start
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
port: ${{ secrets.PORT }}
script: |
docker load -i /opt/backend-tar/backend_dev.tar.gz
cd /var/www/aihomework/dev
docker-compose down
docker-compose up -d
- name: Checkout repository
uses: actions/checkout@v4

- name: Build Docker image
run: |
docker build -t backend_dev .
- name: Save Docker image to tarball
run: |
docker save backend_dev | gzip > backend_dev.tar.gz
- name: Install sshpass
run: sudo apt-get install sshpass

- name: Upload to server
run: |
sshpass -p ${{ secrets.PASSWORD }} scp -o StrictHostKeyChecking=no backend_dev.tar.gz ${{ secrets.USERNAME }}@${{ secrets.HOST }}:/opt/backend-tar/
env:
SSH_HOST: ${{ secrets.HOST }}
SSH_USERNAME: ${{ secrets.USERNAME }}
SSH_PASSWORD: ${{ secrets.PASSWORD }}

- name: Load Docker image on server and start
run: |
sshpass -p ${{ secrets.PASSWORD }} ssh -o StrictHostKeyChecking=no ${{ secrets.USERNAME }}@${{ secrets.HOST }} "
docker load -i /opt/backend-tar/backend_dev.tar.gz
cd /var/www/aihomework/dev
docker-compose down
docker-compose up -d
"
env:
SSH_HOST: ${{ secrets.HOST }}
SSH_USERNAME: ${{ secrets.USERNAME }}
SSH_PASSWORD: ${{ secrets.PASSWORD }}

0 comments on commit 5b19914

Please sign in to comment.