This commit is contained in:
parent
5b894854d4
commit
585a8ad8ca
36
.github/workflows/deploy.yml
vendored
Normal file
36
.github/workflows/deploy.yml
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
---
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout cuqmbr/homelab repository
|
||||
run: git clone https://git.cuqmbr.xyz/cuqmbr/homelab.git --depth 1 --branch main --single-branch
|
||||
- name: Setup ansible
|
||||
run: apt-get update && apt-get install ansible-core -y
|
||||
- name: Add SSH key
|
||||
env:
|
||||
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
|
||||
run: |
|
||||
mkdir -p ~/.ssh
|
||||
echo "${{secrets.ANSIBLE_SSH_KEY}}" > ~/.ssh/key
|
||||
chmod 600 ~/.ssh/key
|
||||
ssh-agent -a $SSH_AUTH_SOCK > /dev/null
|
||||
ssh-add ~/.ssh/key
|
||||
# Without the workaroud can't establish connection to targeted server
|
||||
- name: Connect directly to bastion
|
||||
env:
|
||||
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
|
||||
run: |
|
||||
ssh -o StrictHostKeyChecking=no gitea-actions@bastion.cuqmbr.home 'cat /etc/hostname'
|
||||
- name: Run ansible playbook
|
||||
env:
|
||||
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
|
||||
run: |
|
||||
cd ./homelab/ansible
|
||||
ansible-playbook -u gitea-actions --ssh-common-args "-o StrictHostKeyChecking=no -o ProxyCommand='ssh -p 22 -W %h:%p -q gitea-actions@bastion.cuqmbr.home'" --private-key ~/.ssh/key -b --become-method doas --start-at-task 'Install hugo deb package from github.' --extra-vars "hugo_git_repo=${{github.server_url}}/${{github.repository}}.git hugo_git_refspec=${{github.ref}} hugo_git_commit=${{github.sha}}" -i inventories/dev/hosts.yml 20_main_page.yml
|
Loading…
Reference in New Issue
Block a user