Skip to content

Commit 03bc96e

Browse files
authored
Merge pull request #198 from ralfhandl/main-check-restricted-files
Workflow to complain if a pull request changes restricted files
2 parents 567f8a2 + 7834083 commit 03bc96e

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
- "versions/[0-9].[0-9].[0-9].md"
12+
13+
jobs:
14+
check-files:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v5 # checkout repo content
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Check changed files
22+
shell: bash
23+
run: |
24+
if [[ "${{ github.event.pull_request.head.repo.full_name }}" == "OAI/Overlay-Specification" ]] && \
25+
[[ "${{ github.event.pull_request.base.repo.full_name }}" == "OAI/Overlay-Specification" ]]; then
26+
27+
if [[ "${{ github.event.pull_request.head.ref }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+-rel$ ]] && \
28+
[[ "${{ github.event.pull_request.base.ref }}" == "main" ]]; then
29+
echo Release from ${{ github.event.pull_request.head.ref }} to main
30+
exit 0
31+
fi
32+
fi
33+
34+
echo This PR contains changes to files that should not be changed:
35+
echo
36+
git diff --compact-summary origin/${{ github.event.pull_request.base.ref }} origin/${{ github.event.pull_request.head.ref }} -- versions/[0-9].[0-9].[0-9].md
37+
38+
exit 1

0 commit comments

Comments
 (0)