diff --git a/.github/workflows/Pull_Request.yml b/.github/workflows/Pull_Request.yml index ef73682..05c5880 100644 --- a/.github/workflows/Pull_Request.yml +++ b/.github/workflows/Pull_Request.yml @@ -32,9 +32,8 @@ jobs: USER_NAME: "${{ github.event.pull_request.user.login }}" LINK: "${{ github.event.pull_request._links.commits.href }}" run: | - # TODO: change later to /main/ - chmod +x "${GITHUB_WORKSPACE}/pr/.github/workflows/scripts/authorValidation.sh" - "${GITHUB_WORKSPACE}/pr/.github/workflows/scripts/authorValidation.sh" + chmod +x "${GITHUB_WORKSPACE}/pr/.github/workflows/scripts/author_validation.sh" + "${GITHUB_WORKSPACE}/pr/.github/workflows/scripts/author_validation.sh" - name: Read PR package version if: ${{ env.skipVersionValidation == 'False' }} diff --git a/.github/workflows/scripts/authorValidation.sh b/.github/workflows/scripts/author_validation.sh similarity index 81% rename from .github/workflows/scripts/authorValidation.sh rename to .github/workflows/scripts/author_validation.sh index 3bf9985..798758c 100644 --- a/.github/workflows/scripts/authorValidation.sh +++ b/.github/workflows/scripts/author_validation.sh @@ -8,7 +8,7 @@ if [ $USER_NAME = "$dependabotName" ]; then echo "$dependabotName was detected as PR creator" - # get commits (for this PR) from github + # get commits (for this PR) from GitHub wget --quiet --method GET -O commits.json $LINK # extract from json response @@ -19,32 +19,29 @@ then echo "Committer count: $committersLength" echo "Author count: $authorsLength" - # check if there were more than one author (not only dependabot committed) + # check if there is more than one author (not only dependabot committed) if [ $committersLength -gt 1 ] || [ $authorsLength -gt 1 ]; then echo 'There are too many committers and/or authors for a valid PR branch by $dependabotName' exit 1 else - # extract the only left committer & author + # extract the remaining committer and author committer=$( jq -r '.[0]' <<< $committers ) author=$( jq -r '.[0]' <<< $authors ) echo "Committer: $committer" echo "Author: $author" - # check again if committer is same as dependabot name to be sure + # check if committer and author values have expected dependabot identifier values if [ $committer != "$committerName" ] || [ $author != "$dependabotName" ]; then echo 'Committer and/or author do not have a valid value' exit 1 else - - # set environment variable echo 'Committer and author are valid' echo "skipVersionValidation=True" >> $GITHUB_ENV fi fi else - # set environment variable echo "$dependabotName was not detected as PR creator" echo "skipVersionValidation=False" >> $GITHUB_ENV -fi \ No newline at end of file +fi