Skip to content

release workflow, fixes for module pr #33

release workflow, fixes for module pr

release workflow, fixes for module pr #33

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 }}";
const regex = /\/modules\/([^/]+)\/[^/]+/g;
const matches = paths.match(regex);
if (!matches) {
return [];
}
// Extract the module names from the matches
const moduleNames = matches.map(match => {
return match.replace('/modules/', '').split('/')[0];
});
// Remove duplicates and return the unique module names
const uniqueModuleNames = Array.from(new Set(moduleNames));
console.log(uniqueModuleNames);
return uniqueModuleNames;
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