-
Notifications
You must be signed in to change notification settings - Fork 0
66 lines (54 loc) · 1.68 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
name: Deploy Project
on:
release:
types: [published]
jobs:
push_to_registries:
name: Run Apache Load Balancer
runs-on: ubuntu-20.04
permissions:
contents: read
packages: write
steps:
# Step 1: Check out the repository
- name: Checkout repository
uses: actions/checkout@v3
# Step 2: Set up Terraform
- name: Set up Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.5.6 # Replace with your required version
# Step 4: Install Ansible
- name: Install Ansible
run: |
sudo apt update
sudo apt install -y ansible
- name: Install jq
run: sudo apt install -y jq
- name: Write SSH Private Key
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
run: |
echo "$SSH_PRIVATE_KEY" > id_ecdsa
chmod 600 id_ecdsa
cat id_ecdsa
- name: Write SSH Public Key
env:
SSH_PUBLIC_KEY: ${{ secrets.SSH_PUBLIC_KEY }}
run: |
echo "$SSH_PUBLIC_KEY" > id_ecdsa.pub
chmod 600 id_ecdsa.pub
- name: Fix provider permissions
run: chmod -R +x .terraform/providers
# Step 5: Initialize Terraform
- name: Initialize Terraform
run: terraform init
# Step 6: Plan Terraform deployment
- name: Plan Terraform
run: terraform plan
# Step 7: Apply Terraform configuration
- name: Apply Terraform
run: terraform apply -auto-approve
# Step 12: Run Ansible playbook
- name: Run Ansible Playbook
run: ansible-playbook -i ansible/inventory ansible/playbook.yml