Files
N8N/.gitea/workflows/deploy.yml
2026-05-21 13:12:12 +01:00

70 lines
1.8 KiB
YAML

name: Deploy VM and App
on:
workflow_dispatch:
inputs:
tfvars_file:
description: "Which tfvars file to use"
required: true
default: "single.tfvars.example"
type: choice
options:
- single.tfvars.example
- multi.tfvars.example
jobs:
terraform-deploy:
runs-on: ubuntu-latest
defaults:
run:
working-directory: terraform
steps:
- uses: actions/checkout@v4
- uses: hashicorp/setup-terraform@v4
- name: Select tfvars
run: cp "${{ inputs.tfvars_file }}" terraform.tfvars
- name: Terraform init
run: terraform init
- name: Terraform apply
run: terraform apply -auto-approve
- name: Write inventory
run: |
mkdir -p ../ansible/inventory
terraform output -json vm_ipv4_addresses | jq -r '
to_entries[] | "[app]\n\(.value) ansible_user=cloud"
' > ../ansible/inventory/hosts.ini
- name: Write tags
run: terraform output -json vm_tags > ../ansible/vm_tags.json
ansible-configure:
needs: terraform
runs-on: ubuntu-latest
defaults:
run:
working-directory: ansible
steps:
- uses: actions/checkout@v4
- name: Install Ansible
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y ansible
- name: Set up SSH
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
echo -e "Host *\n\tStrictHostKeyChecking no\n\tUserKnownHostsFile=/dev/null\n" > ~/.ssh/config
- name: Run playbook
run: |
ansible-playbook playbooks/docker_copy.yml -i inventory/inventory.yml -u cloud --private-key ~/.ssh/id_rsa