Skip to content

Commit 7c6dba2

Browse files
committed
Complain if pull request changes restricted files
1 parent 567f8a2 commit 7c6dba2

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: check-restricted-files
2+
3+
# Author: @ralfhandl
4+
# Issue: https://github.com/OAI/OpenAPI-Specification/issues/3432
5+
6+
# This workflow fails if restricted files are changed in a pull request
7+
8+
on:
9+
pull_request:
10+
paths:
11+
- "schemas/v[0-9].[0-9]/*.yaml"
12+
- "versions/[0-9].[0-9].[0-9].md"
13+
14+
jobs:
15+
check-files:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v5 # checkout repo content
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Check changed files
23+
shell: bash
24+
run: |
25+
if [[ "${{ github.event.pull_request.head.repo.full_name }}" == "OAI/Overlay-Specification" ]] && \
26+
[[ "${{ github.event.pull_request.base.repo.full_name }}" == "OAI/Overlay-Specification" ]]; then
27+
28+
if [[ "${{ github.event.pull_request.head.ref }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+-rel$ ]] && \
29+
[[ "${{ github.event.pull_request.base.ref }}" == "main" ]]; then
30+
echo Release from ${{ github.event.pull_request.head.ref }} to main
31+
exit 0
32+
fi
33+
fi
34+
35+
echo This PR contains changes to files that should not be changed:
36+
echo
37+
git diff --compact-summary origin/${{ github.event.pull_request.base.ref }} origin/${{ github.event.pull_request.head.ref }} -- schemas/v[0-9].[0-9]/*.yaml versions/[0-9].[0-9].[0-9].md
38+
39+
exit 1

0 commit comments

Comments
 (0)