diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 10b72a6..fbf37f5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,6 +2,8 @@ name: PR Verification Workflow permissions: issues: write + pull-requests: write + on: pull_request: types: [opened, synchronize, reopened] @@ -19,38 +21,19 @@ jobs: #!/bin/bash set -e - # Function to check file content - function check_file_content() { - if [ ! -s "$1" ]; then - echo "File $1 is empty" - echo "::set-output name=valid::false" - return 1 - fi - } - VALID=true EXPECTED_PATH_PATTERN="^.*_book_app/add_book_features/(create_book\.txt|list_all_books\.txt)$" - # Loop through all files in the PR for file in $(git diff --name-only origin/main...HEAD); do echo "Checking $file" - # Check if the file path matches the expected pattern - if [[ ! $file =~ $EXPECTED_PATH_PATTERN ]]; then - echo "Invalid file path for $file" + if [[ ! $file =~ $EXPECTED_PATH_PATTERN ]] || [ ! -s "$file" ]; then + echo "Invalid file path or empty file: $file" VALID=false - break fi - - # Check file content - check_file_content "$file" || VALID=false done - if [ "$VALID" = true ]; then - echo "::set-output name=valid::true" - else - echo "::set-output name=valid::false" - fi + echo "::set-output name=valid::$VALID" - name: Label PR if: always() @@ -60,11 +43,12 @@ jobs: script: | const isValid = ${{ steps.verify_files.outputs.valid }}; const prNumber = context.payload.pull_request.number; - const labels = isValid ? ['valid'] : ['invalid']; + const label = isValid === 'true' ? 'valid' : 'invalid'; github.rest.issues.addLabels({ owner: context.repo.owner, repo: context.repo.repo, issue_number: prNumber, - labels: labels + labels: [label] }); + diff --git a/Adithya_Krishnan_book_app/add_book_features/create_book.txt b/Adithya_Krishnan_book_app/add_book_features/create_book.txt new file mode 100644 index 0000000..8f07373 --- /dev/null +++ b/Adithya_Krishnan_book_app/add_book_features/create_book.txt @@ -0,0 +1 @@ +Adithya_Krishnan_book_app/add_book_features/create_book.txt diff --git a/Adithya_Krishnan_book_app/add_book_features/ejdsaxio.txt b/Adithya_Krishnan_book_app/add_book_features/ejdsaxio.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/Adithya_Krishnan_book_app/add_book_features/ejdsaxio.txt @@ -0,0 +1 @@ + diff --git a/README.md b/README.md index 57ae6ca..cbab413 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ # dump pr test + + +cool diff --git a/alongppt/rr.txt b/alongppt/rr.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/alongppt/rr.txt @@ -0,0 +1 @@ + diff --git a/hey.md b/hey.md new file mode 100644 index 0000000..8add6ac --- /dev/null +++ b/hey.md @@ -0,0 +1 @@ +helllo diff --git a/wsl.md b/wsl.md new file mode 100644 index 0000000..e4762de --- /dev/null +++ b/wsl.md @@ -0,0 +1 @@ +#hello