Skip to content

Commit 527c92c

Browse files
authored
change to different approach
1 parent 4676a72 commit 527c92c

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

.github/workflows/django.yml

+18-9
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,25 @@ jobs:
2828
# - name: Run Tests
2929
# run: |
3030
# python manage.py test
31-
- name: Deploy to Server
32-
env:
33-
SSH_PRIVATE_KEY: ${{ secrets.SSH_KEY }}
34-
SSH_HOST: ${{ secrets.SSH_HOST }}
35-
SSH_USERNAME: ${{ secrets.SSH_USER }}
31+
- name: Configure SSH
32+
run: |
33+
mkdir -p ~/.ssh/
34+
echo "$SSH_KEY" > ~/.ssh/production.key
35+
chmod 600 ~/.ssh/production.key
36+
cat >>~/.ssh/config <<END
37+
Host production
38+
HostName $SSH_HOST
39+
User $SSH_USER
40+
IdentityFile ~/.ssh/production.key
41+
StrictHostKeyChecking no
42+
END
43+
env:
44+
SSH_USER: ${{ secrets.STAGING_SSH_USER }}
45+
SSH_KEY: ${{ secrets.STAGING_SSH_KEY }}
46+
SSH_HOST: ${{ secrets.STAGING_SSH_HOST }}
47+
- name: Deploy to Server
3648
run: |
37-
eval `ssh-agent -s`
38-
echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
39-
ssh-keyscan -H "$SSH_HOST" >> ~/.ssh/known_hosts
40-
ssh $SSH_USERNAME@$SSH_HOST '
49+
ssh production '
4150
cd /home/django/bakeup/ &&
4251
git pull origin main &&
4352
source /home/django/djangoenv/bin/activate &&

0 commit comments

Comments
 (0)