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: jobs:
deploy: run_pull:
name: run pull
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: Set up SSH key - name: install ssh keys
run: | run: |
env install -m 600 -D /dev/null ~/.ssh/id_rsa
mkdir -p ~/.ssh echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
echo "${{ secrets.ARTIFACT_SSH_KEY }}" > ~/.ssh/id_rsa ssh-keyscan -H ${{ secrets.SSH_HOST }} > ~/.ssh/known_hosts
chmod 600 ~/.ssh/id_rsa - name: connect and pull
ssh-keyscan -p 22 ${{ secrets.ARTIFACT_HOST }} >> ~/.ssh/known_hosts run: ssh ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "cd ${{ secrets.WORK_DIR }} && git checkout ${{ secrets.MAIN_BRANCH }} && git pull && exit"
sudo apt-get install sshpass - name: cleanup
run: rm -rf ~/.ssh
- 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