diff --git a/.github/branchNameValidation.sh b/.github/branchNameValidation.sh index e071a65a..20cd856f 100755 --- a/.github/branchNameValidation.sh +++ b/.github/branchNameValidation.sh @@ -3,6 +3,7 @@ set -e local_branch=${1} +[ -z "${1}" ] && local_branch=$(git rev-parse --abbrev-ref HEAD) valid_branch='^[a-z][a-z0-9-]*$' @@ -15,7 +16,7 @@ join_by() { local IFS='|'; echo "$*"; } #creates glob match to check for reserved words used in branch names which would trigger failures glob=$(join_by $(for i in ${reserved_words[@]}; do echo "^$i-|-$i$|-$i-|^$i$"; done;)) -if [[ ! $local_branch =~ $valid_branch ]] || [[ $local_branch =~ $glob ]] || [[ ${#local_branch} -gt 64 ]]; then +if [[ ! $local_branch =~ $valid_branch ]] || [[ $local_branch =~ $glob ]] || [[ ${#local_branch} -gt 20 ]]; then echo """ ------------------------------------------------------------------------------------------------------------------------------ ERROR: Please read below @@ -28,7 +29,7 @@ if [[ ! $local_branch =~ $valid_branch ]] || [[ $local_branch =~ $glob ]] || [[ Therefore, the branch name must be a valid service name. Branch name must be all lower case with no spaces and no underscores. From Serverless: - A service name should only contain alphanumeric (case sensitive) and hyphens. It should start with an alphabetic character and shouldnt exceed 128 characters. + A service name should only contain alphanumeric (case sensitive) and hyphens. It should start with an alphabetic character and shouldnt exceed 20 characters. For Github Actions support, please push your code to a new branch with a name that meets Serverless' service name requirements. So, make a new branch with a name that begins with a letter and is made up of only letters, numbers, and hyphens... then delete this branch. ------------------------------------------------------------------------------------------------------------------------------ diff --git a/.github/workflows/pr-notification.yml b/.github/workflows/pr-notification.yml index 9969731f..ea00af1e 100755 --- a/.github/workflows/pr-notification.yml +++ b/.github/workflows/pr-notification.yml @@ -9,7 +9,6 @@ permissions: contents: write issues: write pull-requests: write - jobs: endpoint: runs-on: ubuntu-latest @@ -40,7 +39,7 @@ jobs: application_endpoint_url="endpoint not found" fi echo "application_endpoint_url=$application_endpoint_url" >> $GITHUB_OUTPUT - + outputs: application_endpoint_url: ${{ steps.getendpoint.outputs.application_endpoint_url }} @@ -48,7 +47,7 @@ jobs: runs-on: ubuntu-latest needs: - endpoint - # avoiding notifications for automated Snyk Pull Requests and draft pull requests + # avoiding notifications for automated Snyk Pull Requests and draft pull requests if: github.actor != 'mdct-github-service-account' && !github.event.pull_request.draft steps: - name: Slack Notification diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 42170178..dde1b168 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -3,6 +3,17 @@ name: Pull-request on: [pull_request] jobs: + prchecks: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: "3.10" + - name: Configure pre-commit to skip branch name validation + run: | + echo "SKIP=branch-name-validation" >> $GITHUB_ENV + - uses: pre-commit/action@v3.0.1 linting: runs-on: ubuntu-latest steps: @@ -11,7 +22,6 @@ jobs: uses: actions/setup-python@v4 with: python-version: "3.10" - - uses: pre-commit/action@v3.0.1 jest-frontend: runs-on: ubuntu-latest steps: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 084b0188..e73a4955 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,4 +1,4 @@ -exclude: 'seed-section-base-*' +exclude: "seed-section-base-*" repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.0.1 @@ -38,4 +38,11 @@ repos: - repo: https://github.com/zricethezav/gitleaks rev: v8.12.0 hooks: - - id: gitleaks \ No newline at end of file + - id: gitleaks + - repo: local + hooks: + - id: branch-name-validation + name: branch-name-validation + entry: .github/branchNameValidation.sh + language: script + pass_filenames: false