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

89 lines
2.1 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
steps:
- uses: actions/checkout@v4
- name: Check files & Select tfvars
shell: bash
run: |
pwd
cd terraform
cp ${{ inputs.tfvars_file }} terraform.tfvars
ls
- uses: hashicorp/setup-terraform@v4
- name: Check path
run: pwd
- name: Terraform init
run: terraform init
- name: Terraform apply
run: terraform apply -auto-approve
- name: Check files
shell: bash
run: |
cd ..
pwd
ls
- name: Upload generated files
uses: actions/upload-artifact@v7
with:
name: terraform-outputs
path: |
ansible/inventory/inventory.yml
terraform/vm_data.yml
ansible-configure:
needs: terraform-deploy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download generated files
uses: actions/download-artifact@v7
with:
name: terraform-outputs
path: .
- 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: Setup Ansible Directories
run: |
pwd
cat ansible/inventory/inventory.yml
ls -r
- name: Run playbook
run: |
ansible-playbook ansible/playbooks/docker_copy.yml -i ansible/inventory/inventory.yml -u cloud --private-key ~/.ssh/id_rsa