Update .forgejo/workflows/Deploy_to_server.yaml

This commit is contained in:
Maksim Bengraf 2024-07-12 22:09:55 +00:00
parent 9c4a88210a
commit 0c7c260ab8

View file

@ -1,28 +1,18 @@
name: Deploy to server
on: push
jobs:
deploy:
run_pull:
name: run pull
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up SSH key
- name: install ssh keys
run: |
env
mkdir -p ~/.ssh
echo "${{ secrets.ARTIFACT_SSH_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan -p 22 ${{ secrets.ARTIFACT_HOST }} >> ~/.ssh/known_hosts
sudo apt-get install sshpass
- name: Deploy to server
run: |
sshpass -p '${{ secrets.PSWD }}' ssh -v -o StrictHostKeyChecking=no ${{ secrets.USER }}@${{ secrets.HOST }} <<'ENDSSH'
cd ${{ secrets.APP_PATH }}
git pull
docker stop ${{ secrets.APP_NAME }}
docker system prune -f
export ${{ secrets.API_KEY_NAME }}=${{ secrets.API_KEY }}
make deploy_headless
ENDSSH
install -m 600 -D /dev/null ~/.ssh/id_rsa
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
ssh-keyscan -H ${{ secrets.SSH_HOST }} > ~/.ssh/known_hosts
- name: connect and pull
run: ssh ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "cd ${{ secrets.WORK_DIR }} && git checkout ${{ secrets.MAIN_BRANCH }} && git pull && exit"
- name: cleanup
run: rm -rf ~/.ssh