-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: add workflows for generating docs, validating pr titles, pre-comm…
…it, and creating releases with semantic versioning
- Loading branch information
1 parent
ef1ce4d
commit 3a54e0b
Showing
4 changed files
with
225 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: Generate terraform docs | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
docs: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.pull_request.head.ref }} | ||
|
||
- name: Render terraform docs and push changes back to PR | ||
uses: terraform-docs/gh-actions@main | ||
with: | ||
working-dir: . | ||
recursive: true | ||
recursive-path: modules | ||
output-file: README.md | ||
output-method: replace | ||
git-push: true | ||
|
||
- name: Ensure newline at end of README files | ||
run: | | ||
find . -type f -name 'README.md' -exec sh -c 'echo >> "{}"' \; | ||
working-directory: ${{ github.workspace }} | ||
|
||
- name: Commit changes | ||
run: | | ||
git config --local user.email "action@github.com" | ||
git config --local user.name "GitHub Action" | ||
git add . | ||
git commit -m "Fix newline at end of README.md files" | ||
git push origin ${{ github.event.pull_request.head.ref }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: 'Validate PR title' | ||
|
||
on: | ||
pull_request_target: | ||
types: | ||
- opened | ||
- edited | ||
- synchronize | ||
|
||
jobs: | ||
main: | ||
name: Validate PR title | ||
runs-on: ubuntu-latest | ||
steps: | ||
# Please look up the latest version from | ||
# https://github.com/amannn/action-semantic-pull-request/releases | ||
- uses: amannn/action-semantic-pull-request@v5.4.0 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
# Configure which types are allowed. | ||
# Default: https://github.com/commitizen/conventional-commit-types | ||
types: | | ||
fix | ||
feat | ||
docs | ||
ci | ||
chore | ||
# Configure that a scope must always be provided. | ||
requireScope: false | ||
# Configure additional validation for the subject based on a regex. | ||
# This example ensures the subject starts with an uppercase character. | ||
subjectPattern: ^[A-Z].+$ | ||
# If `subjectPattern` is configured, you can use this property to override | ||
# the default error message that is shown when the pattern doesn't match. | ||
# The variables `subject` and `title` can be used within the message. | ||
subjectPatternError: | | ||
The subject "{subject}" found in the pull request title "{title}" | ||
didn't match the configured pattern. Please ensure that the subject | ||
starts with an uppercase character. | ||
# For work-in-progress PRs you can typically use draft pull requests | ||
# from Github. However, private repositories on the free plan don't have | ||
# this option and therefore this action allows you to opt-in to using the | ||
# special "[WIP]" prefix to indicate this state. This will avoid the | ||
# validation of the PR title and the pull request checks remain pending. | ||
# Note that a second check will be reported if this is enabled. | ||
wip: true | ||
# When using "Squash and merge" on a PR with only one commit, GitHub | ||
# will suggest using that commit message instead of the PR title for the | ||
# merge commit, and it's easy to commit this by mistake. Enable this option | ||
# to also validate the commit message for one commit PRs. | ||
validateSingleCommit: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
name: Pre-Commit | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- master | ||
pull_request: | ||
branches: | ||
- main | ||
- master | ||
|
||
env: | ||
TERRAFORM_DOCS_VERSION: v0.18.0 | ||
TFLINT_VERSION: v0.52.0 | ||
|
||
jobs: | ||
collectInputs: | ||
name: Collect workflow inputs | ||
runs-on: ubuntu-latest | ||
outputs: | ||
directories: ${{ steps.dirs.outputs.directories }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Get root directories | ||
id: dirs | ||
uses: clowdhaus/terraform-composite-actions/directories@v1.9.0 | ||
|
||
preCommitMinVersions: | ||
name: Min TF pre-commit | ||
needs: collectInputs | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
directory: ${{ fromJson(needs.collectInputs.outputs.directories) }} | ||
steps: | ||
# https://github.com/orgs/community/discussions/25678#discussioncomment-5242449 | ||
- name: Delete huge unnecessary tools folder | ||
run: | | ||
rm -rf /opt/hostedtoolcache/CodeQL | ||
rm -rf /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk | ||
rm -rf /opt/hostedtoolcache/Ruby | ||
rm -rf /opt/hostedtoolcache/go | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Terraform min/max versions | ||
id: minMax | ||
uses: clowdhaus/terraform-min-max@v1.3.0 | ||
with: | ||
directory: ${{ matrix.directory }} | ||
|
||
- name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }} | ||
# Run only validate pre-commit check on min version supported | ||
if: ${{ matrix.directory != '.' }} | ||
uses: clowdhaus/terraform-composite-actions/pre-commit@v1.9.0 | ||
with: | ||
terraform-version: ${{ steps.minMax.outputs.minVersion }} | ||
tflint-version: ${{ env.TFLINT_VERSION }} | ||
args: 'terraform_validate --color=always --show-diff-on-failure --files ${{ matrix.directory }}/*' | ||
|
||
- name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }} | ||
# Run only validate pre-commit check on min version supported | ||
if: ${{ matrix.directory == '.' }} | ||
uses: clowdhaus/terraform-composite-actions/pre-commit@v1.9.0 | ||
with: | ||
terraform-version: ${{ steps.minMax.outputs.minVersion }} | ||
tflint-version: ${{ env.TFLINT_VERSION }} | ||
args: 'terraform_validate --color=always --show-diff-on-failure --files $(ls *.tf)' | ||
|
||
preCommitMaxVersion: | ||
name: Max TF pre-commit | ||
runs-on: ubuntu-latest | ||
needs: collectInputs | ||
steps: | ||
# https://github.com/orgs/community/discussions/25678#discussioncomment-5242449 | ||
- name: Delete huge unnecessary tools folder | ||
run: | | ||
rm -rf /opt/hostedtoolcache/CodeQL | ||
rm -rf /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk | ||
rm -rf /opt/hostedtoolcache/Ruby | ||
rm -rf /opt/hostedtoolcache/go | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.pull_request.head.ref }} | ||
repository: ${{github.event.pull_request.head.repo.full_name}} | ||
|
||
- name: Terraform min/max versions | ||
id: minMax | ||
uses: clowdhaus/terraform-min-max@v1.3.0 | ||
|
||
- name: Pre-commit Terraform ${{ steps.minMax.outputs.maxVersion }} | ||
uses: clowdhaus/terraform-composite-actions/pre-commit@v1.9.0 | ||
with: | ||
terraform-version: ${{ steps.minMax.outputs.maxVersion }} | ||
tflint-version: ${{ env.TFLINT_VERSION }} | ||
terraform-docs-version: ${{ env.TERRAFORM_DOCS_VERSION }} | ||
install-hcledit: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: 'Module Release' | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
release: | ||
name: Release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
persist-credentials: false | ||
fetch-depth: 0 | ||
|
||
- name: Release | ||
uses: cycjimmy/semantic-release-action@v2 | ||
with: | ||
semantic_version: 18.0.0 | ||
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 }} |