From b09efe8de07bc613cac83448ec96c166f88c8918 Mon Sep 17 00:00:00 2001 From: priynsh aggarwal <142209650+priyanshaggarwal001@users.noreply.github.com> Date: Mon, 21 Oct 2024 16:27:12 +0530 Subject: [PATCH] Create check_screenshot.yml this code checks for any screenshot in pr for readibility --- .github/workflows/check_screenshot.yml | 27 ++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/check_screenshot.yml diff --git a/.github/workflows/check_screenshot.yml b/.github/workflows/check_screenshot.yml new file mode 100644 index 0000000..7497bf7 --- /dev/null +++ b/.github/workflows/check_screenshot.yml @@ -0,0 +1,27 @@ +name: Check Screenshot in PR + +on: + pull_request: + types: [opened, edited, synchronize] + +jobs: + check-screenshot: + runs-on: ubuntu-latest + + steps: + - name: Check if screenshot is attached + id: check_screenshot + run: | + # Fetch the PR body (description) using jq + PR_BODY=$(jq -r '.pull_request.body' "$GITHUB_EVENT_PATH") + + # Log the PR body for debugging (you can remove this later) + echo "PR BODY: $PR_BODY" + + # Check if the PR body contains a GitHub-hosted image URL or image extensions (png, jpg, jpeg, gif) + if echo "$PR_BODY" | grep -E "https://github.com/.+/assets/|\.png|\.jpg|\.jpeg|\.gif"; then + echo "Screenshot found!" + else + echo "No screenshot found! Please attach a screenshot to your PR." + exit 1 # Fail the workflow if no screenshot is found + fi