Skip to content

Azure CosmosDB SQL & MongoDB #48

Azure CosmosDB SQL & MongoDB

Azure CosmosDB SQL & MongoDB #48

Workflow file for this run

name: Pull request
on:
- pull_request
jobs:
collectInputs:
name: Collect workflow inputs
runs-on: ubuntu-latest
outputs:
directories: ${{ steps.dirs.outputs.matrix }}
steps:
# Checkout the repository to the GitHub Actions runner
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
# Find all subdirectories within "modules/" and "examples/"
- name: Get root directories
id: dirs
run: echo "matrix=$(ls -d {modules,examples}/* | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT
validatePR:
name: Validate PR
runs-on: ubuntu-latest
needs: collectInputs
strategy:
matrix:
directory: ${{ fromJson(needs.collectInputs.outputs.directories) }}
steps:
# Checkout the repository to the GitHub Actions runner
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
# Install the latest version of Terraform
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
# Initialize terraform and validate submodules
- name: Terraform validate
working-directory: ${{ matrix.directory }}
run: |
if [[ -d ".terraform" ]]; then echo "removing exisiting .terraform directory"; rm -rf .terraform; fi
terraform workspace new ${{ github.run_id }}
terraform init
terraform validate
updateDocumentation:
name: Update READMEs
needs: validatePR
runs-on: ubuntu-latest
steps:
# Checkout the repository to the GitHub Actions runner
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
# Update READMEs using terraform-docs
- name: Render terraform docs inside the README.md and push changes back to PR branch
uses: terraform-docs/[email protected]
with:
args: --recursive-include-main=false --read-comments=false
working-dir: modules,examples
recursive: true
recursive-path: .
output-file: README.md
output-method: inject
git-push: "true"
formatConfig:
name: Fix Terraform file formatting
runs-on: ubuntu-latest
permissions:
contents: write
steps:
# Checkout the repository to the GitHub Actions runner
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
# Format Terraform modules
- name: Terraform fmt modules
uses: dflook/terraform-fmt@v1
with:
path: modules/
# Format Terraform examples
- name: Terraform fmt examples
uses: dflook/terraform-fmt@v1
with:
path: examples/
# Push changes to PR
- name: Commit changes to PR
uses: stefanzweifel/git-auto-commit-action@v5