Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 25 additions & 16 deletions .github/workflows/get-terraform-dir.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,31 @@ on:
outputs:
terraform-dir:
description: The terraform directory to initialise
value: ${{ jobs.terraform-directory.outputs.terraform-dir }}
value: ${{ jobs.terraform-directory.outputs.terraform-matrix }}

# Declare default permissions as read only.
permissions:
contents: read

# TODO: Define single list of files to use in both steps
# See: https://github.com/3ware/workflows/issues/101
jobs:
terraform-directory:
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
terraform-dir: ${{ steps.get-terraform-dir.outputs.all_changed_files }}
terraform-matrix: ${{ steps.get-terraform-matrix.outputs.all_changed_files }}
steps:
- name: Checkout repository
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
with:
persist-credentials: true # changed-files unable to authenticate if false

# Find the directory where terraform files have been changed.
- name: Get terraform directory
id: get-terraform-dir
uses: tj-actions/changed-files@cbda684547adc8c052d50711417fa61b428a9f88 # v41.1.2
# Output a JSON object which can be used for matrix strategies
- name: Get terraform directory matrix
id: get-terraform-matrix
uses: tj-actions/changed-files@4918e1183080b35a085c91c8abc9e6adc4de61a1 # v42.1.0
continue-on-error: true # Allows workflow to proceed if no files found
with:
files: |
Expand All @@ -34,27 +37,33 @@ jobs:
**/*.tftpl
**/*.hcl
dir_names: true
json: true
escape_json: false
matrix: true

- name: Format Get terraform directory output
if: ${{ steps.get-terraform-dir.outputs.all_changed_files != '[]' }}
env:
TF_DIR_JSON: ${{ steps.get-terraform-dir.outputs.all_changed_files }}
run: |
echo "TF_DIR=$(echo ${{ env.TF_DIR_JSON }} | sed 's:[][""]::g' | sed 's:,:\n:g')" >> "$GITHUB_ENV"
# Find the directory where terraform files have been changed.
# Output text for use with the job summary steps
- name: Get terraform directory Summary
id: get-terraform-sum
uses: tj-actions/changed-files@4918e1183080b35a085c91c8abc9e6adc4de61a1 # v42.1.0
continue-on-error: true # Allows workflow to proceed if no files found
with:
files: |
**/*.tf
**/*.tfvars
**/*.tftpl
**/*.hcl
dir_names: true

- name: Terraform directory summary
if: ${{ steps.get-terraform-dir.outputs.all_changed_files != '[]' }}
if: ${{ steps.get-terraform-sum.outputs.all_changed_files != '[]' }}
run: |
echo "# :white_check_mark: Terraform file changes detected" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "## Terraform changes have been detected in the following directories:" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
printf '%s\n' "$TF_DIR" >> $GITHUB_STEP_SUMMARY
printf '%s\n' ${{ steps.get-terraform-sum.outputs.all_changed_files }} >> $GITHUB_STEP_SUMMARY

- name: Terraform directory summary
if: ${{ steps.get-terraform-dir.outputs.all_changed_files == '[]' }}
if: ${{ steps.get-terraform-sum.outputs.all_changed_files == '[]' }}
run: |
echo "# :negative_squared_cross_mark: Terraform file changes not detected" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-title.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Validate PR title

on:
pull_request_target:
types: [opened, edited]
types: [opened, edited, synchronize]
branches: [main]
workflow_call: {}

Expand Down