initial template
This commit is contained in:
46
.gitea/workflows/deploy.yml
Normal file
46
.gitea/workflows/deploy.yml
Normal file
@@ -0,0 +1,46 @@
|
||||
name: Deploy VM and App
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
terraform:
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: terraform
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: hashicorp/setup-terraform@v3
|
||||
|
||||
- name: Terraform init
|
||||
run: terraform init
|
||||
|
||||
- name: Terraform apply
|
||||
run: terraform apply -auto-approve
|
||||
|
||||
- name: Write inventory from output
|
||||
run: |
|
||||
IP=$(terraform output -raw vm_ipv4_address)
|
||||
mkdir -p ../ansible/inventory
|
||||
printf '[app]\n%s ansible_user=cloud\n' "$IP" > ../ansible/inventory/hosts.ini
|
||||
|
||||
- name: Write tags file
|
||||
run: |
|
||||
TAGS=$(terraform output -json vm_tags)
|
||||
echo "$TAGS" > ../terraform/vm_tags.json
|
||||
|
||||
deploy:
|
||||
needs: terraform
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install Ansible
|
||||
run: |
|
||||
python3 -m pip install --upgrade pip
|
||||
pip install ansible community.docker
|
||||
|
||||
- name: Deploy app
|
||||
run: ansible-playbook -i ansible/inventory/hosts.ini ansible/playbooks/deploy.yml
|
||||
Reference in New Issue
Block a user