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.
|
2024-01-23 19:24:52 +01:00
|
|
|
name: Protect files
|
2022-08-10 20:19:52 +02:00
|
|
|
|
|
|
|
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
|
2024-01-23 19:24:52 +01:00
|
|
|
runs-on: ubuntu-22.04
|
2022-08-10 20:19:52 +02:00
|
|
|
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:
|
2024-01-23 19:24:52 +01:00
|
|
|
- name: Check out repo
|
2024-10-30 16:23:50 +01:00
|
|
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
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 }}
|