2022-08-10 20:19:52 +02:00
|
|
|
# Runs if there are changes to the paths: list.
|
|
|
|
# Starts a matrix job to check for modified files, then sets output based on the results.
|
|
|
|
# The input decides if the label job is ran, adding a label to the PR.
|
|
|
|
---
|
|
|
|
|
|
|
|
name: Protect Files
|
|
|
|
|
|
|
|
on:
|
|
|
|
pull_request:
|
2022-08-24 16:42:59 +02:00
|
|
|
types:
|
2022-08-10 20:19:52 +02:00
|
|
|
- opened
|
|
|
|
- synchronize
|
2022-08-24 16:42:59 +02:00
|
|
|
- unlabeled
|
|
|
|
paths:
|
2022-08-11 17:54:37 +02:00
|
|
|
- "util/Migrator/DbScripts/**.sql"
|
2022-08-10 20:19:52 +02:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
changed-files:
|
|
|
|
name: Check for file changes
|
|
|
|
runs-on: ubuntu-20.04
|
|
|
|
outputs:
|
2022-08-24 16:42:59 +02:00
|
|
|
changes: ${{steps.check-changes.outputs.changes_detected}}
|
2022-08-10 20:19:52 +02:00
|
|
|
|
|
|
|
strategy:
|
|
|
|
fail-fast: true
|
|
|
|
matrix:
|
|
|
|
include:
|
|
|
|
- name: Database Scripts
|
|
|
|
path: util/Migrator/DbScripts
|
2022-08-24 16:42:59 +02:00
|
|
|
label: "DB-migrations-changed"
|
2022-08-10 20:19:52 +02:00
|
|
|
steps:
|
2022-08-24 16:42:59 +02:00
|
|
|
- name: Checkout repo
|
2023-09-18 16:39:38 +02:00
|
|
|
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
2022-08-10 20:19:52 +02:00
|
|
|
with:
|
2022-08-24 16:42:59 +02:00
|
|
|
fetch-depth: 2
|
2022-08-10 20:19:52 +02:00
|
|
|
|
|
|
|
- name: Check for file changes
|
|
|
|
id: check-changes
|
|
|
|
run: |
|
2022-08-24 16:42:59 +02:00
|
|
|
MODIFIED_FILES=$(git diff --name-only --diff-filter=M HEAD~1)
|
2022-08-10 20:19:52 +02:00
|
|
|
|
2022-08-24 16:42:59 +02:00
|
|
|
for file in $MODIFIED_FILES
|
|
|
|
do
|
|
|
|
if [[ $file == *"${{ matrix.path }}"* ]]; then
|
2022-12-05 17:12:42 +01:00
|
|
|
echo "changes_detected=true" >> $GITHUB_OUTPUT
|
2022-08-10 20:19:52 +02:00
|
|
|
break
|
2022-12-05 17:12:42 +01:00
|
|
|
else echo "changes_detected=false" >> $GITHUB_OUTPUT
|
2022-08-10 20:19:52 +02:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2022-08-24 16:42:59 +02:00
|
|
|
- name: Add label to pull request
|
2023-08-30 00:22:09 +02:00
|
|
|
if: contains(steps.check-changes.outputs.changes_detected, 'true')
|
2023-06-13 15:57:30 +02:00
|
|
|
uses: andymckay/labeler@e6c4322d0397f3240f0e7e30a33b5c5df2d39e90 # 1.0.4
|
2022-08-10 20:19:52 +02:00
|
|
|
with:
|
|
|
|
add-labels: ${{ matrix.label }}
|