Skip to content

M2 food4future - Added workflow page and screenshots #205

M2 food4future - Added workflow page and screenshots

M2 food4future - Added workflow page and screenshots #205

name: Check Project Update PR
on:
pull_request:
paths:
- 'content/ss24/**'
workflow_dispatch:
jobs:
check-pr-title:
runs-on: ubuntu-latest
env:
PR_TITLE: ${{ github.event.pull_request.title }}
steps:
- uses: actions/checkout@v4
with:
submodules: false
fetch-depth: 1
- name: check pr title starts with project id
run: |
./bin/check-project-update-pr/check-title.sh "$PR_TITLE"
- name: check project folder name convention
run: |
PID=$(bin/check-project-update-pr/extract_pid_from_pr_title.sh "$PR_TITLE")
ls content/ss24/**/$PID-*
check-disk-usage:
if: ${{ ! startsWith(github.event.pull_request.title, 'STW') }}
needs: check-pr-title
runs-on: ubuntu-latest
# Required permissions
permissions:
pull-requests: read
steps:
- uses: actions/checkout@v4
with:
submodules: false
fetch-depth: 1
- name: check disk usage
env:
PR_TITLE: ${{ github.event.pull_request.title }}
run: |
PID=$(bin/check-project-update-pr/extract_pid_from_pr_title.sh "$PR_TITLE")
./bin/check-project-update-pr/disk-usage.sh $PID
get-files-in-pr:
if: ${{ ! startsWith(github.event.pull_request.title, 'STW') }}
name: "Download changed files list"
needs: check-pr-title
runs-on: ubuntu-latest
# Required permissions
permissions:
pull-requests: read
steps:
- uses: actions/checkout@v4
with:
submodules: false
fetch-depth: 1
- name: extract project id
id: extract_pid
env:
PR_TITLE: ${{ github.event.pull_request.title }}
run: |
project_id=$(bin/check-project-update-pr/extract_pid_from_pr_title.sh "$PR_TITLE")
pid_ok=$?
echo "project_id=$project_id" >> $GITHUB_OUTPUT
echo "pid_ok=$pid_ok" >> $GITHUB_OUTPUT
exit 0
- name: 'download changed files from gh api'
uses: dorny/paths-filter@v3
id: filter
with:
list-files: 'shell'
filters: |
in_project:
- 'content/**/${{ steps.extract_pid.outputs.project_id }}-*/**'
other_files:
- '!content/**/${{ steps.extract_pid.outputs.project_id }}-*/**'
with_spaces:
- '**/*\ *'
- name: create artifact dir and empty files
run: |
mkdir changed_files
touch changed_files/files-project.txt
touch changed_files/files-other.txt
touch changed_files/files-with-spaces.txt
- name: 'fail if pr contains files with spaces'
if: (steps.filter.outputs.with_spaces == 'true')
env:
all_files: ${{ steps.filter.outputs.with_spaces_files }}
run: |
echo "--------- PR contains files with spaces in their name - EXITING."
echo $all_files | tr ' ' '\n'
exit 101
- name: write changed files
if: (steps.filter.outputs.in_project == 'true')
env:
all_files: ${{ steps.filter.outputs.in_project_files }}
run: |
echo "--------- project_files:"
pr_adds_files=$(bin/check-project-update-pr/remove_deleted_files.sh $all_files)
echo $pr_adds_files | tr ' ' '\n'
echo $pr_adds_files > changed_files/files-project.txt
- name: 'files outside of project folder'
if: (steps.filter.outputs.other_files == 'true')
env:
all_files: ${{ steps.filter.outputs.other_files_files }}
run: |
echo "--------- non_project_files (may not be part of project update PR!):"
pr_adds_files=$(bin/check-project-update-pr/remove_deleted_files.sh $all_files)
echo $pr_adds_files | tr ' ' '\n'
echo $pr_adds_files > changed_files/files-other.txt
- name: list artifact files
run: |
ls -lart changed_files
echo "------------ changed_files/files-project.txt"
cat changed_files/files-project.txt | tr ' ' '\n'
echo "------------ changed_files/files-other.txt"
cat changed_files/files-other.txt | tr ' ' '\n'
- name: Upload changed-files.txt
uses: actions/upload-artifact@v4
with:
name: changed_files
path: changed_files/
retention-days: 1
check_artifact:
if: ${{ ! startsWith(github.event.pull_request.title, 'STW') }}
name: "look for artifact files"
needs: get-files-in-pr
runs-on: ubuntu-latest
steps:
- name: Download changed_files.txt
uses: actions/download-artifact@v4
with:
name: changed_files
- name: list artifact files
run: |
tree
ls -lart
echo "------------ files-project.txt"
cat files-project.txt | tr ' ' '\n'
echo "------------ files-other.txt"
cat files-other.txt | tr ' ' '\n'
check_files_in_pr:
if: ${{ ! startsWith(github.event.pull_request.title, 'STW') }}
name: "check for files outside of project folder"
needs: get-files-in-pr
runs-on: ubuntu-latest
steps:
- name: Download changed_files.txt
uses: actions/download-artifact@v4
with:
name: changed_files
- name: 'check for files outside the project folder'
run: |
FILES="$(cat files-other.txt)"
if ! [ -z "$FILES" ]; then
echo "--------- non_project_files found in PR:"
echo $FILES | tr ' ' '\n'
echo "ERROR: these files may not be changed within a project update PR!"
exit 14
else
echo "none found -> ok!"
fi
check_for_cats_download:
if: ${{ ! startsWith(github.event.pull_request.title, 'STW') }}
name: "check for cat template files"
needs: get-files-in-pr
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: false
- name: Download changed_files.txt
uses: actions/download-artifact@v4
with:
name: changed_files
- name: check for template cat images
env:
PR_TITLE: ${{ github.event.pull_request.title }}
run: |
FILES="$(cat files-project.txt)"
./bin/check-project-update-pr/check-for-cats-based-on-filenames.sh "$FILES"
check_file_name_convention:
if: ${{ ! startsWith(github.event.pull_request.title, 'STW') }}
name: "check file name conventions"
needs: get-files-in-pr
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: false
- name: Download changed_files.txt
uses: actions/download-artifact@v4
with:
name: changed_files
- name: check name conventions
run: |
echo "----------------"
cat files-project.txt
echo "----------------"
FILES="$(cat files-project.txt)"
./bin/check-project-update-pr/check-file-names.sh "$FILES"