Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9cb07d9cef | |||
| 809d26349b | |||
| 63cc96d602 | |||
| 4db2abc990 | |||
| f7fa3bbd47 | |||
| 2a20398c87 | |||
| 3fe7ea4c36 |
@@ -2,6 +2,9 @@ name: Build
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
@@ -14,7 +17,7 @@ jobs:
|
|||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Install Terraform/Terragrunt
|
- name: Install Packages
|
||||||
run: |
|
run: |
|
||||||
dnf install terraform terragrunt vault jq -y
|
dnf install terraform terragrunt vault jq -y
|
||||||
|
|
||||||
@@ -22,16 +25,15 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
VAULT_ROLEID: ${{ secrets.TERRAFORM_NOMAD_VAULT_ROLEID }}
|
VAULT_ROLEID: ${{ secrets.TERRAFORM_NOMAD_VAULT_ROLEID }}
|
||||||
run: |
|
run: |
|
||||||
env
|
|
||||||
make plan
|
make plan
|
||||||
|
|
||||||
- name: Show Plans
|
- name: Show Plans
|
||||||
run: |
|
run: |
|
||||||
find /workspace -type f -name "*.plan"
|
find /workspace -type f -name "*.plan"
|
||||||
|
|
||||||
#- name: Upload Artifacts
|
- name: Upload Artifacts
|
||||||
# uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
# with:
|
with:
|
||||||
# name: plans
|
name: plans
|
||||||
# path: /workspace/unkin/rpmbuilder/dist/*/*.rpm
|
path: /workspace/unkin/terraform-nomad/plans/*.plan
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
name: Deploy
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
runs-on: almalinux-8
|
||||||
|
container:
|
||||||
|
image: git.query.consul/unkin/almalinux8-runnerdnd:latest
|
||||||
|
options: --privileged
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Download Artifacts
|
||||||
|
run: |
|
||||||
|
mkdir -p /workspace/unkin/terraform-nomad/plans
|
||||||
|
export RUN_ID=$((GITHUB_RUN_NUMBER - 1))
|
||||||
|
export PLANS_URL="https://git.query.consul/${GITHUB_REPOSITORY}/actions/runs/${RUN_ID}/artifacts/plans"
|
||||||
|
export MAX_RETRIES=5
|
||||||
|
export RETRY_COUNT=0
|
||||||
|
echo "Attempting to download plans from ${PLANS_URL}"
|
||||||
|
while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do
|
||||||
|
curl -L -o /workspace/plans.zip "${PLANS_URL}" && break || true
|
||||||
|
echo "Plans file not available yet. Retrying in 10 seconds... ($((RETRY_COUNT + 1))/$MAX_RETRIES)"
|
||||||
|
RETRY_COUNT=$((RETRY_COUNT + 1))
|
||||||
|
sleep 10
|
||||||
|
done
|
||||||
|
if [ ! -f /workspace/plans.zip ]; then
|
||||||
|
echo "Failed to download plans file after $MAX_RETRIES attempts."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "Plans file downloaded. Extracting..."
|
||||||
|
unzip /workspace/plans.zip -d /workspace/unkin/terraform-nomad/plans
|
||||||
|
echo "Plans file extracted successfully."
|
||||||
|
|
||||||
|
- name: Show Plans
|
||||||
|
run: |
|
||||||
|
find /workspace -type f -name "*.plan"
|
||||||
|
|
||||||
|
- name: Install Packages
|
||||||
|
run: |
|
||||||
|
dnf install terraform terragrunt vault jq -y
|
||||||
|
|
||||||
|
- name: Run Terraform Apply
|
||||||
|
env:
|
||||||
|
VAULT_ROLEID: ${{ secrets.TERRAFORM_NOMAD_VAULT_ROLEID }}
|
||||||
|
run: |
|
||||||
|
make apply
|
||||||
@@ -20,15 +20,14 @@ clean:
|
|||||||
rm -rf plans
|
rm -rf plans
|
||||||
|
|
||||||
init:
|
init:
|
||||||
$(call vault_env)
|
$(call vault_env) && \
|
||||||
env
|
|
||||||
terragrunt --terragrunt-working-dir $(ENV_DIR) init
|
terragrunt --terragrunt-working-dir $(ENV_DIR) init
|
||||||
|
|
||||||
plan: init
|
plan: init
|
||||||
@mkdir -p $(PLAN_DIR)
|
@mkdir -p $(PLAN_DIR)
|
||||||
$(call vault_env)
|
$(call vault_env) && \
|
||||||
terragrunt --terragrunt-working-dir $(ENV_DIR) plan -out=$(PLAN_FILE)
|
terragrunt --terragrunt-working-dir $(ENV_DIR) plan -out=$(PLAN_FILE)
|
||||||
|
|
||||||
apply:
|
apply:
|
||||||
$(call vault_env)
|
$(call vault_env) && \
|
||||||
terragrunt --terragrunt-working-dir $(ENV_DIR) apply $(PLAN_FILE)
|
terragrunt --terragrunt-working-dir $(ENV_DIR) apply $(PLAN_FILE)
|
||||||
|
|||||||
Reference in New Issue
Block a user