Skip to content

Commit

Permalink
Adds GitHub actions (#7)
Browse files Browse the repository at this point in the history
* adds base GitHub Actions

* updates Terraform Actions

* updates minimally required Terraform version to `0.12.20` because of `try`
  • Loading branch information
ksatirli authored Feb 15, 2020
1 parent 40fca69 commit c782265
Show file tree
Hide file tree
Showing 6 changed files with 159 additions and 24 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/code-quality-terraform.yml
Original file line number Diff line number Diff line change
@@ -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
88 changes: 88 additions & 0 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
@@ -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
18 changes: 18 additions & 0 deletions .github/workflows/repository-management.yml
Original file line number Diff line number Diff line change
@@ -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 }}
22 changes: 0 additions & 22 deletions .github/workflows/terraform.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion terraform.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
terraform {
required_version = ">= 0.12.0"
required_version = ">= 0.12.20"

required_providers {
aws = "> 2.10.0"
Expand Down

0 comments on commit c782265

Please sign in to comment.