diff --git a/.github/workflows/code-quality-terraform.yml b/.github/workflows/code-quality-terraform.yml new file mode 100644 index 0000000..1f144a0 --- /dev/null +++ b/.github/workflows/code-quality-terraform.yml @@ -0,0 +1,51 @@ +--- + +name: "Code Quality: Terraform" + +on: + pull_request: + +env: + TERRAFORM_VERSION: 0.12.20 + TERRAFORM_ACTIONS_COMMENT: true + +jobs: + terraform: + name: terraform + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + with: + fetch-depth: 1 + + - name: Run `terraform fmt` + uses: hashicorp/terraform-github-actions@master + with: + tf_actions_version: ${{ env.TERRAFORM_VERSION }} + tf_actions_subcommand: fmt + tf_actions_working_dir: '.' + tf_actions_comment: ${{ env.TERRAFORM_ACTIONS_COMMENT }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Run `terraform init` + uses: hashicorp/terraform-github-actions@master + with: + tf_actions_version: ${{ env.TERRAFORM_VERSION }} + tf_actions_subcommand: init + tf_actions_working_dir: '.' + tf_actions_comment: ${{ env.TERRAFORM_ACTIONS_COMMENT }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Run `terraform validate` + uses: hashicorp/terraform-github-actions@master + with: + tf_actions_version: ${{ env.TERRAFORM_VERSION }} + tf_actions_subcommand: validate + tf_actions_working_dir: '.' + tf_actions_comment: ${{ env.TERRAFORM_ACTIONS_COMMENT }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + AWS_REGION: xx-xxxx-0 diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml new file mode 100644 index 0000000..80e882a --- /dev/null +++ b/.github/workflows/code-quality.yml @@ -0,0 +1,88 @@ +--- + +name: Code Quality + +on: + pull_request: + +env: + PARENT_ORG: operatehappy + META_PATH: dotfiles-org + SELF_PATH: repository + PYTHON_VERSION: 3.8 + PYTHON_ARCH: x64 + PRECOMMIT_CACHE_PATH: ".cache/pre-commit" + PRECOMMIT_VERSION: 1.18.3 + PRECOMMIT_CONFIG: ".pre-commit-config.yaml" + +jobs: + pre-commit: + runs-on: ubuntu-latest + name: pre-commit + + steps: + - name: Checkout Meta Repository + uses: actions/checkout@v2 + with: + repository: ${{ env.PARENT_ORG }}/${{ env.META_PATH }} + ref: master + path: ${{ env.META_PATH }} + fetch-depth: 1 + + - name: Checkout Repository + uses: actions/checkout@v2 + with: + fetch-depth: 1 + path: ${{ env.SELF_PATH }} + + - name: Setup Python + uses: actions/setup-python@v1 + with: + python-version: ${{ env.PYTHON_VERSION }} + architecture: ${{ env.PYTHON_ARCH }} + + - name: Update and Restore pip Binaries Cache + uses: actions/cache@v1 + id: cache-pip-binaries + with: + path: "${{ env.pythonLocation }}/bin" + key: "pip-binaries-${{ env.PYTHON_VERSION }}-${{ env.PRECOMMIT_VERSION }}" + + - name: Update and Restore pip Packages Cache + uses: actions/cache@v1 + id: cache-pip-packages + with: + path: "${{ env.pythonLocation }}/lib/python${{ env.PYTHON_VERSION }}/site-packages" + key: "pip-packages-${{ env.PYTHON_VERSION }}-${{ env.PRECOMMIT_VERSION }}" + + - name: Update and Restore pre-commit Cache + uses: actions/cache@v1 + id: cache-precommit-hooks + with: + path: "~/${{ env.PRECOMMIT_CACHE_PATH }}" + key: ${{ hashFiles(format('{0}/{1}/{2}', github.workspace, env.META_PATH, env.PRECOMMIT_CONFIG )) }} + + - name: Install `pre-commit` via `pip` + run: | + pip \ + install "pre-commit==${{ env.PRECOMMIT_VERSION }}" + shell: sh + if: steps.cache-pip-binaries.outputs.cache-hit != 'true' && steps.cache-pip-packages.outputs.cache-hit != 'true' + + - name: Setup `pre-commit` + run: | + pre-commit \ + install \ + --config "${{ github.workspace }}${{ env.UPSTREAM_REP }}/${{ env.PRECOMMIT_CONFIG }}" + shell: sh + working-directory: "${{ github.workspace }}/${{ env.SELF_PATH }}" + if: steps.cache-precommit.outputs.cache-hit != 'true' + + - name: Run `pre-commit` + run: | + pre-commit \ + run \ + --config "${{ github.workspace }}/${{ env.META_PATH }}/${{ env.PRECOMMIT_CONFIG }}" \ + --all-files + working-directory: "${{ github.workspace }}/${{ env.SELF_PATH }}" + shell: sh diff --git a/.github/workflows/repository-management.yml b/.github/workflows/repository-management.yml new file mode 100644 index 0000000..082ae9d --- /dev/null +++ b/.github/workflows/repository-management.yml @@ -0,0 +1,18 @@ +--- + +name: Repository Management + +on: + pull_request: + +jobs: + assign-pr-to-author: + runs-on: ubuntu-latest + name: assign-pr-to-author + + steps: + - name: Assign Pull Request to Author + uses: technote-space/assign-author@v1 + if: github.event_name == 'pull_request' && github.event.action == 'opened' + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml deleted file mode 100644 index 0a525cd..0000000 --- a/.github/workflows/terraform.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: Terraform -on: [pull_request] - -jobs: - on-pull-request: - name: On Pull Request - runs-on: ubuntu-latest - steps: - - name: Terraform - Format - uses: hashicorp/terraform-github-actions/fmt@v0.4.4 - env: - TF_ACTION_WORKING_DIR: "." - - - name: Terraform - Init - uses: hashicorp/terraform-github-actions/init@v0.4.4 - env: - TF_ACTION_WORKING_DIR: "." - - - name: Terraform - Validate - uses: hashicorp/terraform-github-actions/validate@v0.4.4 - env: - TF_ACTION_WORKING_DIR: "." diff --git a/README.md b/README.md index 99d7407..c5efd8a 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ ## Requirements -This module requires Terraform version `0.12.0` or newer. +This module requires Terraform version `0.12.20` or newer. ## Dependencies diff --git a/terraform.tf b/terraform.tf index 11046c7..615cf82 100644 --- a/terraform.tf +++ b/terraform.tf @@ -1,5 +1,5 @@ terraform { - required_version = ">= 0.12.0" + required_version = ">= 0.12.20" required_providers { aws = "> 2.10.0"