From fa1f64a2621dc6f8a9824d2b7b1a486595c00bbf Mon Sep 17 00:00:00 2001 From: Ralf Handl Date: Sun, 2 Mar 2025 17:26:33 +0100 Subject: [PATCH 1/2] Create check-restricted-files.yaml Simple workflow to check for changes to files in schemas and versions folder --- .github/workflows/check-restricted-files.yaml | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/check-restricted-files.yaml diff --git a/.github/workflows/check-restricted-files.yaml b/.github/workflows/check-restricted-files.yaml new file mode 100644 index 0000000000..8dab26a634 --- /dev/null +++ b/.github/workflows/check-restricted-files.yaml @@ -0,0 +1,30 @@ +name: check-restricted-files + +# Autor: @ralfhandl +# Issue: https://github.com/OAI/OpenAPI-Specification/issues/3432 + +# This workflow checks for changes of restricted files in a pull request + +on: + - pull_request + +jobs: + check-files: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Check changed files + shell: bash + run: | + set +e + + git diff --exit-code --name-only ${{ github.event.pull_request.head.sha }} ${{ github.event.pull_request.base.sha }} \ + -- schemas versions + if [[ $? -ne 0 ]]; then + echo This PR contains changes to files that should not be changed on ${{ github.event.pull_request.base.ref }} + exit 1 + fi From a963ad6e05230c631e45e2b1c8785069d403afe8 Mon Sep 17 00:00:00 2001 From: Ralf Handl Date: Tue, 4 Mar 2025 20:03:26 +0100 Subject: [PATCH 2/2] Simplified approach --- .github/workflows/check-restricted-files.yaml | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/.github/workflows/check-restricted-files.yaml b/.github/workflows/check-restricted-files.yaml index 8dab26a634..6badca1994 100644 --- a/.github/workflows/check-restricted-files.yaml +++ b/.github/workflows/check-restricted-files.yaml @@ -1,30 +1,22 @@ name: check-restricted-files -# Autor: @ralfhandl +# Author: @ralfhandl # Issue: https://github.com/OAI/OpenAPI-Specification/issues/3432 -# This workflow checks for changes of restricted files in a pull request +# This workflow fails if restricted files are changed in a pull request on: - - pull_request + pull_request: + paths: + - 'schemas/**/*.yaml' + - 'versions/*.md' jobs: check-files: runs-on: ubuntu-latest steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Check changed files shell: bash run: | - set +e - - git diff --exit-code --name-only ${{ github.event.pull_request.head.sha }} ${{ github.event.pull_request.base.sha }} \ - -- schemas versions - if [[ $? -ne 0 ]]; then - echo This PR contains changes to files that should not be changed on ${{ github.event.pull_request.base.ref }} - exit 1 - fi + echo This PR contains changes to files that should not be changed + exit 1