Compare commits
2
Commits
445527f05a
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c06165bc3b | ||
|
|
804f84ecad |
@@ -55,20 +55,41 @@ jobs:
|
||||
deploy:
|
||||
needs: docker-build-and-push
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install Ansible
|
||||
run: apt-get update && apt-get install -y ansible
|
||||
run: |
|
||||
apt-get update
|
||||
apt-get install -y ansible openssh-client
|
||||
|
||||
- name: Set up SSH key
|
||||
env:
|
||||
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
run: |
|
||||
mkdir -p ~/.ssh
|
||||
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/deploy_key
|
||||
printf '%s\n' "$SSH_PRIVATE_KEY" > ~/.ssh/deploy_key
|
||||
chmod 600 ~/.ssh/deploy_key
|
||||
ssh-keygen -y -f ~/.ssh/deploy_key >/dev/null
|
||||
|
||||
- name: Trust server host key
|
||||
run: |
|
||||
ssh-keyscan -H ${{ secrets.SERVER_IP }} >> ~/.ssh/known_hosts
|
||||
ssh-keyscan -H "${{ secrets.SERVER_IP }}" >> ~/.ssh/known_hosts
|
||||
|
||||
- name: Test SSH
|
||||
run: |
|
||||
ssh \
|
||||
-i ~/.ssh/deploy_key \
|
||||
-o StrictHostKeyChecking=yes \
|
||||
"${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP }}" \
|
||||
'echo SSH works'
|
||||
|
||||
- name: Run Ansible playbook
|
||||
run: |
|
||||
ansible-playbook -i "${{ secrets.SERVER_IP }}," ansible/restart_compose.yml \
|
||||
ansible-playbook \
|
||||
-i "${{ secrets.SERVER_IP }}," \
|
||||
ansible/restart_compose.yml \
|
||||
--user "${{ secrets.SERVER_USER }}" \
|
||||
--private-key ~/.ssh/deploy_key
|
||||
Reference in new issue
Block a user