ci: fix ci
This commit is contained in:
1 parent
804f84ecad
commit
c06165bc3b
1 file changed
+26
-5
@@ -55,20 +55,41 @@ jobs:
|
|||||||
deploy:
|
deploy:
|
||||||
needs: docker-build-and-push
|
needs: docker-build-and-push
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install Ansible
|
- 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
|
- name: Set up SSH key
|
||||||
|
env:
|
||||||
|
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||||
run: |
|
run: |
|
||||||
mkdir -p ~/.ssh
|
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
|
chmod 600 ~/.ssh/deploy_key
|
||||||
|
ssh-keygen -y -f ~/.ssh/deploy_key >/dev/null
|
||||||
|
|
||||||
- name: Trust server host key
|
- name: Trust server host key
|
||||||
run: |
|
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
|
- name: Run Ansible playbook
|
||||||
run: |
|
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 }}" \
|
--user "${{ secrets.SERVER_USER }}" \
|
||||||
--private-key ~/.ssh/deploy_key
|
--private-key ~/.ssh/deploy_key
|
||||||
Reference in new issue
Block a user