Skip to content

Merge pull request #34 from using-system/features/improve-workflows #4

Merge pull request #34 from using-system/features/improve-workflows

Merge pull request #34 from using-system/features/improve-workflows #4

name: TF Modules - Create a new release
on:
push:
branches:
- main
paths:
- "terraform/modules/**"
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
id-token: write
contents: write
jobs:
changed-modules:
name: Get changed files
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.changed-files.outputs.all_changed_files }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v42
with:
json: true
quotepath: false
escape_json: false
dir_names: 'true'
files: terraform/modules/**
dir_names_max_depth: '3'
- name: List all changed files
run: echo '${{ steps.changed-files.outputs.all_changed_files }}'
release:
runs-on: ubuntu-latest
needs: changed-modules
strategy:
fail-fast: false
max-parallel: 1
matrix:
module: ${{ fromJson(needs.changed-modules.outputs.matrix) }}
steps:
- name: Checkout
uses: actions/checkout@v4
- id: extract_module
run: |
module=$(echo '${{ matrix.module }}' | sed 's|modules/||')
echo "module=${module}" >> $GITHUB_OUTPUT
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/[email protected]
with:
release_branches: main
default_bump: "patch"
tag_prefix: "${{ steps.extract_module.outputs.module }}-v"
create_annotated_tag: true
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Release
uses: softprops/action-gh-release@v1
with:
name: ${{ steps.tag_version.outputs.new_tag }}
body: ${{ steps.tag_version.outputs.changelog }}
tag_name: ${{ steps.tag_version.outputs.new_tag }}
generate_release_notes: true
token: ${{ secrets.GITHUB_TOKEN }}