Skip to content

improve workflows

improve workflows #29

name: Allowed Files in PR
on:
pull_request:
workflow_dispatch:
jobs:
check_files_in_pr:
runs-on: ubuntu-latest
# Required permissions
permissions:
pull-requests: read
steps:
- uses: actions/checkout@v4
with:
submodules: false
fetch-depth: 20
- name: extract project id
continue-on-error: true
id: extract_pid
env:
PR_TITLE: ${{ github.event.pull_request.title }}
run: |
project_id=$(bin/extract_pid_from_pr_title.sh $PR_TITLE)
pid_ok=$?
echo "project_id=$project_id" >> $GITHUB_OUTPUT
echo "pid_ok=$pid_ok"
- name: 'changed files'
uses: dorny/paths-filter@v3
id: filter
with:
list-files: 'shell'
filters: |
contains_project_files:
- 'content/ss24/**'
- 'content/ws23/**'
in_project:
- 'content/**/${{ steps.extract_pid.outputs.project_id }}-*/**'
other_files:
- '!content/**/${{ steps.extract_pid.outputs.project_id }}-*/**'
- name: files in project folder
if: (steps.filter.outputs.in_project == 'true')
run: |
echo "--------- project_files:"
echo ${{ steps.filter.outputs.in_project_files }} | tr ' ' '\n'
- name: 'files outside of project folder'
if: (steps.filter.outputs.other_files == 'true')
run: |
echo "--------- non_project_files (may not be part of project update PR!):"
echo ${{ steps.filter.outputs.other_files_files }} | tr ' ' '\n'
echo "ERROR: found files outside of project folder"
- name: 'fail if both project files present and no project id in title'
if: (steps.filter.outputs.contains_project_files == 'true') && (steps.extract_pid.outputs.project_id != '0')
run: |
echo "ERROR: PR contains both project files and files outside of project indicated by PR Title!"
echo "Extracted id: ${{ steps.extract_pid.outputs.project_id }}"
exit 321
- name: 'fail if both project files and other files present'
if: (steps.filter.outputs.contains_project_files == 'true') && (steps.filter.outputs.other_files == 'true')
run: |
echo "ERROR: PR contains both project files and files outside of project indicated by PR Title!"
echo "Extracted id: ${{ steps.extract_pid.outputs.project_id }}"
exit 321