Skip to content
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

Update to equinix provider #30

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
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
13 changes: 0 additions & 13 deletions .circleci/config.yml

This file was deleted.

57 changes: 57 additions & 0 deletions .github/workflows/documentation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: generate-terraform-docs
# This workflow will generate terraform docs into README.md in the root, examples, and modules folders.
# Source: https://github.com/equinix-labs/terraform-equinix-kubernetes-addons/blob/main/.github/workflows/documentation.yaml

on:
push:
branches:
- main
paths:
- "**/*.tpl"
- "**/*.tf"

permissions:
contents: write # Workflow needs to push new branches to open PRs with docs changes
pull-requests: write # Workflow needs to open PRs with docs changes

jobs:
tf-docs:
name: TF docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
id: actions-checkout
with:
ref: main

- name: Render terraform docs inside the main and the modules README.md files and push changes back to PR branch
id: terraform-docs
uses: terraform-docs/gh-actions@v1
with:
find-dir: .
args: --sort-by required
indention: 2
git-push: "false"

# terraform-docs/gh-actions@v1.0.0 modifies .git files with owner root:root, and the following steps fail with
# insufficient permission for adding an object to repository database .git/objects
# since the expected user is runner:docker. See https://github.com/terraform-docs/gh-actions/issues/90
- name: Fix .git owner
run: sudo chown runner:docker -R .git

- name: Create Pull Request
if: steps.terraform-docs.outputs.num_changed != '0'
uses: peter-evans/create-pull-request@v6
with:
commit-message: "generate-terraform-docs: automated action"
committer: GitHub <noreply@github.com>
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
title: "generate-terraform-docs: automated action"
body: |
Update terraform docs
branch-suffix: timestamp
base: main
signoff: true
delete-branch: true

# TODO(ocobleseqx): https://github.com/peter-evans/enable-pull-request-automerge
28 changes: 28 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: generate-release
# This workflow will generate changelog and release notes.
# Source: https://github.com/terraform-aws-modules/terraform-aws-vpc/blob/master/.github/workflows/release.yml

on:
workflow_dispatch:

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0

- name: Release
uses: cycjimmy/semantic-release-action@v4
with:
semantic_version: 19.0.5
extra_plugins: |
@semantic-release/changelog@6.0.0
@semantic-release/git@10.0.0
conventional-changelog-conventionalcommits@4.6.3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
101 changes: 74 additions & 27 deletions .github/workflows/terraform.yaml
Original file line number Diff line number Diff line change
@@ -1,38 +1,85 @@
name: 'terraform'
# This workflow verifies that the Terraform configs are valid.
# https://learn.hashicorp.com/tutorials/terraform/automate-terraform
name: "run-pre-commit-hooks"
# This workflow runs the pre-commit hooks defined in .pre-commit-config.yaml

on:
push:
branches:
- main
pull_request:
branches: [main]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
name: Test
pre-commit:
runs-on: ${{ matrix.os }}
env:
TF_IN_AUTOMATION: 1
TF_VERSION: ${{ matrix.tf }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
strategy:
matrix:
os: [ubuntu-latest]
tf: [1.1.2]
tf: [1.5.7]
tflint: [v0.50.3]
tfsec: [v1.28.5]
shfmt: [v3.8.0]
shellcheck: [v0.10.0]
permissions:
pull-requests: write
id-token: write
contents: read
steps:
- name: Checkout from Github
uses: actions/checkout@v2
- name: Install Terraform
uses: hashicorp/setup-terraform@v1
with:
terraform_version: ${{ env.TF_VERSION }}
- name: Check Terraform formatting
id: fmt
run: terraform fmt
continue-on-error: true
- name: Initialize Terraform, Modules, and Plugins
id: init
run: terraform init -input=false
- name: Validate Terraform syntax
id: validate
run: terraform validate -no-color
- name: Checkout from Github
uses: actions/checkout@v4

- name: Install Python3
uses: actions/setup-python@v5

- name: Install tflint
uses: terraform-linters/setup-tflint@v4
with:
tflint_version: ${{ matrix.tflint }}

- name: Cache tflint plugin dir
uses: actions/cache@v4
with:
path: ~/.tflint.d/plugins
key: ${{ matrix.os }}-tflint-${{ hashFiles('.tflint.hcl') }}

- name: Install Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: ${{ matrix.tf }}

- name: Config Terraform plugin cache
run: |
echo 'plugin_cache_dir="$HOME/.terraform.d/plugin-cache"' >~/.terraformrc
mkdir --parents ~/.terraform.d/plugin-cache

- name: Cache Terraform
uses: actions/cache@v4
with:
path: |
~/.terraform.d/plugin-cache
key: ${{ runner.os }}-terraform-${{ hashFiles('**/.terraform.lock.hcl') }}
restore-keys: |
${{ runner.os }}-terraform-

- name: Install tfsec
uses: jaxxstorm/action-install-gh-release@v1.11.0
with:
repo: aquasecurity/tfsec
platform: linux
arch: amd64
tag: ${{ matrix.tfsec }}

- name: Install shfmt
uses: jaxxstorm/action-install-gh-release@v1.11.0
with:
repo: mvdan/sh
platform: linux
arch: amd64
tag: ${{ matrix.shfmt }}
extension-matching: disable
rename-to: shfmt
chmod: 0755

- uses: pre-commit/action@v3.0.1
86 changes: 86 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
---
fail_fast: false
repos:
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.88.4
hooks:
- id: terraform_fmt
args:
- "--args=-recursive"
- id: terraform_validate
exclude: "^[^/]+$"
- id: terraform_tflint
args:
- "--args=--config=__GIT_WORKING_DIR__/.tflint.hcl"
- id: terraform_tfsec
args:
- "--args=--soft-fail"

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
# Git style
- id: check-added-large-files
- id: check-merge-conflict
- id: check-vcs-permalinks
- id: forbid-new-submodules
- id: no-commit-to-branch
args: ["--branch", "master"]

# Common errors
- id: end-of-file-fixer
- id: trailing-whitespace
args:
- "--markdown-linebreak-ext=md"
exclude: CHANGELOG.md
- id: check-yaml
args:
- "--allow-multiple-documents"
exclude: |
(?x)^(
examples/|
\.*?.yaml$"
)$
- id: check-json
- id: check-symlinks
- id: check-executables-have-shebangs

# Cross platform
- id: check-case-conflict
- id: mixed-line-ending
args:
- "--fix=lf"

# Security
- id: detect-private-key

# Shell Script Formatter and Markdown Linter
- repo: https://github.com/jumanjihouse/pre-commit-hooks
rev: 3.0.0
hooks:
- id: shfmt
exclude: |
(?x)^(
helpers/helper-script.sh|
scripts/template-script.sh
)$
- id: shellcheck
args:
- "--severity=warning"
- "--source-path=SCRIPTDIR scripts/* helpers/*"
- "--shell=bash"
exclude: |
(?x)^(
helpers/helper-script.sh|
scripts/template-script.sh
)$
- id: markdownlint
exclude: "CHANGELOG.md"

# JSON5 and Yaml Prettyfier
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.1.0
hooks:
- id: prettier
types: [json5, yaml]
exclude: "^examples/"
Loading
Loading