Skip to content

Infra features #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions .github/workflows/ansible-monitoring.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,45 @@
name: Ansible Monitoring

on:
repository_dispatch:
workflow_dispatch:
workflow_run:
workflows: ["Terraform Apply"]
types:
- ansible-monitoring
- completed

jobs:
monitoring-stack-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: infra_features

- name: Get Workflow Run ID
id: get-run-id
run: |
RUN_ID=$(curl -s \
-H "Authorization: Bearer ${{ secrets.TOKEN }}" \
-H "Accept: application/vnd.github+json" \
"https://api.github.com/repos/${{ github.repository }}/actions/workflows/terraform-apply.yml/runs?branch=infra_features&per_page=1" \
| jq -r '.workflow_runs[0].id')
echo "run_id=$RUN_ID" >> $GITHUB_OUTPUT
echo "$RUN_ID"

- name: Write Private Key to File
run: |
echo "${{ secrets.PRIVATE_KEY }}" > ${{ vars.TF_KEY_PAIR_NAME }}.pem
chmod 600 ${{ vars.TF_KEY_PAIR_NAME }}.pem
echo "${{ github.event.client_payload.run_id }}"
echo "${{ github.event.workflow_run.id }}"

- name: Download Ansible Inventory
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: ansible_inventory
github-token: ${{ secrets.TOKEN }}
run-id: ${{ steps.get-run-id.outputs.run_id }}

- name: Verify Ansible Inventory
run: |
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/hello.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Simple Workflow

on:
workflow_dispatch:
workflow_run:
workflows: ["Terraform Apply"]
types:
- completed
push:
branches:
- 'infra_features'

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.8'


19 changes: 10 additions & 9 deletions .github/workflows/terraform-apply.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: infra_features

- name: Write Private Key to File
run: |
Expand All @@ -62,12 +64,11 @@ jobs:
if [ "${{ github.event.inputs.operation }}" = "destroy" ]; then
terraform destroy --auto-approve
else
terraform destroy --auto-approve
terraform apply --auto-approve
fi
working-directory: ./terraform
- name: Upload Ansible Inventory
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ansible_inventory
path: ./terraform/inventory.ini
Expand All @@ -76,15 +77,15 @@ jobs:
echo "public_ip=$(terraform output -raw instance_public_ip)" > public_ip_env.txt
working-directory: ./terraform
- name: Upload Public_IP
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Public_IP
path: |
./public_ip_env.txt
- name: Trigger Ansible Monitoring Workflow
uses: peter-evans/repository-dispatch@v2
with:
event-type: ansible-monitoring
path: ./public_ip_env.txt
# - name: Trigger Ansible Monitoring Workflow
# uses: peter-evans/repository-dispatch@v2
# with:
# token: ${{ secrets.TOKEN }}
# event-type: ansible-monitoring



Expand Down
1 change: 1 addition & 0 deletions terraform/bkp.terraform.tfvars.k
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ traefik_domain = "traefik.cv1.drintech.online"
cert_email = "admin@example.com" # replace with a valid email

Let's move on
just a test
Loading