Skip to content

Improve Validation and Deployment Workflows #10

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

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
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
26 changes: 10 additions & 16 deletions .github/workflows/host_01_production.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
name: Host 01 Production CI
name: Host 01 Production CD

on:
workflow_dispatch:
workflow_dispatch:
pull_request:

permissions:
contents: write
Expand Down Expand Up @@ -60,24 +61,12 @@ jobs:
name: Terraform Apply
needs:
- init_and_plan
if: github.event_name != 'pull_request' && needs.init_and_plan.outputs.planExitcode == 2
if: needs.init_and_plan.outputs.planExitcode == 2
runs-on: Self-Hosted
environment: "Host 01 Production"

steps:

- name: Install Docker
uses: crazy-max/ghaction-setup-docker@v3

- name: Manual Approval 🚦
uses: trstringer/manual-approval@v1
with:
secret: ${{ github.TOKEN }}
approvers: data-tangles
minimum-approvals: 1
issue-title: "Terraform Apply"
issue-body: "Please approve or deny the Terraform Apply operation"
exclude-workflow-initiator-as-approver: false

- name: Checkout 🔔
uses: actions/checkout@v4

Expand All @@ -87,6 +76,11 @@ jobs:
path: ./production/host_01/**
key: ${{ github.sha }}

- name: Install NodeJS 🖥️
uses: actions/setup-node@v4
with:
node-version: 20

- name: Install Terraform ⛰️
uses: hashicorp/setup-terraform@v3

Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/host_02_production.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
name: Host 02 Production CI
name: Host 02 Production CD

on:
workflow_dispatch:
pull_request:

permissions:
contents: write
Expand Down Expand Up @@ -60,8 +61,9 @@ jobs:
name: Terraform Apply
needs:
- init_and_plan
if: github.event_name != 'pull_request' && needs.init_and_plan.outputs.planExitcode == 2
if: needs.init_and_plan.outputs.planExitcode == 2
runs-on: Self-Hosted
environment: "Host 02 Production"

steps:

Expand Down
49 changes: 40 additions & 9 deletions .github/workflows/validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,48 @@ jobs:
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ steps.generate-token.outputs.token }}

- name: Install Terraform ⛰️
uses: hashicorp/setup-terraform@651471c36a6092792c552e8b1bef71e592b462d8 # v3

- name: Run TFLint ✅
uses: terraform-linters/setup-tflint@19a52fbac37dacb22a09518e4ef6ee234f2d4987 # v4
with:
tflint_version: latest

- name: Download and install Terraform Docs
run: |
curl -Lo ./terraform-docs.tar.gz https://github.com/terraform-docs/terraform-docs/releases/download/v0.17.0/terraform-docs-v0.17.0-$(uname)-amd64.tar.gz
tar -xzf terraform-docs.tar.gz
chmod +x terraform-docs
mv terraform-docs /usr/local/bin/terraform-docs

- name: Generate Terraform Docs 🗒️
id: push-terraform-docs-changes
uses: terraform-docs/gh-actions@v1.1.0
run: |
# Get folders which contain .tf files
folder_list=$(find . -name '*.tf' -printf '%h\n' | sort -u)

# Run terraform-docs command for each subfolder
for folder in $folder_list; do
terraform-docs markdown table --output-file README.md "$folder"
done

- name: Run Terraform fmt ✅
run: |
terraform fmt -recursive

- name: Check for changed files 🕵️
uses: tj-actions/verify-changed-files@ab875806658e59162bc5f42e4df5c2d4682c459e # v20
id: verify-changed-files

- name: Commit Terraform code changes 🖊️
if: steps.verify-changed-files.outputs.files_changed == 'true'
uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 # v9
with:
find-dir: .
output-file: README.md
output-method: replace
git-push-user-name: "braid-bot[bot]"
git-push-user-email: "169546839+braid-bot[bot]@users.noreply.github.com"
git-push: "true"
git-commit-message: "docs: 🤖 Update Terraform Docs for Workflow Run ID: ${{ github.run_id }} in Branch: ${{ github.head_ref }}"
default_author: github_actor
author_name: "braid-bot[bot]"
author_email: "169546839+braid-bot[bot]@users.noreply.github.com"
message: |
"🤖 Automated commit for Workflow Run ID: ${{ github.run_id }} in Branch: ${{ github.head_ref }}"

changelog:
name: Generate Changelog 🗒️
Expand Down
18 changes: 14 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
## [0.1.12](https://github.com/binary-braids/terraform-esxi/compare/v0.1.11...v0.1.12) (2024-05-12)


### Bug Fixes

* add environment to host 02 workflow ([27b1edd](https://github.com/binary-braids/terraform-esxi/commit/27b1edda990cc51271c1966e5a5b11706d3bc594))
* change Terraform Docs to bash script instead of action ([2147143](https://github.com/binary-braids/terraform-esxi/commit/214714360decdf5914d5ea9967e88969f4c29dc7))
* correct tf-docs command ([ba30f5b](https://github.com/binary-braids/terraform-esxi/commit/ba30f5bc5033a34ea870d8acc28712fecc6fe2f8))
* Improve Validation and Deployment workflows ([95a4031](https://github.com/binary-braids/terraform-esxi/commit/95a40313366b8a95560bcbe5af57d0fe4b1996fd))
* modify terraform docs action ([3b68ed0](https://github.com/binary-braids/terraform-esxi/commit/3b68ed07e8dfbe09df3eab82db1c3399f7aceeda))
* Remove node install action ([43cb90b](https://github.com/binary-braids/terraform-esxi/commit/43cb90b2e83fa865182cb005a9cb6ef021536e4f))



## [0.1.11](https://github.com/binary-braids/terraform-esxi/compare/v0.1.10...v0.1.11) (2024-05-11)


Expand Down Expand Up @@ -69,7 +83,3 @@



## [0.1.2](https://github.com/binary-braids/terraform-esxi/compare/v0.1.1...v0.1.2) (2024-05-08)



Loading
Loading