Skip to content

M2 - Edited texts on the website #98

M2 - Edited texts on the website

M2 - Edited texts on the website #98

name: Check Project Update PR
on:
pull_request:
workflow_dispatch:
jobs:
hugo-build:
if: github.repository == 'htw-imi-showtime/showtime-website'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: false
- name: Get Theme
run: |
git submodule update --init themes/showtime-theme-2021
- name: Hugo setup
uses: peaceiris/actions-hugo@v3
with:
hugo-version: '0.128.0'
extended: true
- name: Build
run: |
hugo \
--environment staging \
--baseURL "https://htw-imi-showtime.github.io/tryout/" \
--buildDrafts
check-title:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: false
fetch-depth: 1
- name: check pr title starts with project id
id: extract_pid
env:
PR_TITLE: ${{ github.event.pull_request.title }}
run: |
./bin/check-project-update-pr/check-title.sh "$PR_TITLE"
check_disk_usage:
needs: check-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:
name: "Download changed files list"
needs: check-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 }}-*/**'
- name: create artifact dir and empty files
run: |
mkdir changed_files
touch changed_files/files-project.txt
touch changed_files/files-other.txt
- name: write changed files
if: (steps.filter.outputs.in_project == 'true')
run: |
echo "--------- project_files:"
echo ${{ steps.filter.outputs.in_project_files }} | tr ' ' '\n'
echo ${{ steps.filter.outputs.in_project_files }} > changed_files/files-project.txt
- 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 ${{ steps.filter.outputs.other_files_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:
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:
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:
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:
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"