Skip to content

release workflow, fixes for module pr #30

release workflow, fixes for module pr

release workflow, fixes for module pr #30

Workflow file for this run

name: Modules PR Workflow
on:
pull_request:
paths:
- modules/**
permissions:
pull-requests: write
contents: write
jobs:
find-changes:
name: Find in modules folder
runs-on: ubuntu-latest
outputs:
changed-modules: ${{ steps.changed-modules.outputs.result }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v39
with:
files_ignore: '.github/workflows/**'
- name: Get changed modules
id: changed-modules
uses: actions/github-script@v6.4.1
with:
script: |
console.log("${{ steps.changed-files.outputs.all_modified_files }}");
const paths = "${{ steps.changed-files.outputs.all_modified_files }}";
// Use a regular expression to find all occurrences of "/modules/.../..." or "modules/.../..."
const regex = /\/modules\/([^/]+)/g;
const matches = paths.match(regex);
if (!matches) {
return [];
}
// Extract the module paths from the matches
const modulePaths = matches.map(match => {
return match.replace('/modules/', '');
});
return modulePaths;
console.log(uniqueModulePaths);
return uniqueModulePaths;
update-readme:
name: Update README for changed modules
runs-on: ubuntu-latest
needs: find-changes
strategy:
matrix:
module: ${{ needs.find-changes.outputs.changed-modules }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 2
ref: ${{ github.event.pull_request.head.ref }}
- name: Render terraform docs and push changes back to PR
uses: terraform-docs/gh-actions@v1
with:
working-dir: ${{ matrix.module }}
output-file: README.md
output-method: inject
git-push: "true"
module-review:
name: Individual module review
runs-on: ubuntu-latest
needs: find-changes
strategy:
matrix:
module: ${{ needs.find-changes.outputs.changed-modules }}
defaults:
run:
working-directory: ${{ matrix.module }}
steps:
- name: Checkout
uses: actions/checkout@v4
- run: terraform init
- run: terraform fmt -check
- run: terraform validate